ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaik_5.4.0.1/rzaikspresultsets.htm

85 lines
4.5 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="Stored procedure result sets" />
<meta name="abstract" content="Define scrollable SQL stored procedure result sets." />
<meta name="description" content="Define scrollable SQL stored procedure result sets." />
<meta name="DC.Relation" scheme="URI" content="rzaikodbcstoredproc.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzaikspresultsets" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Stored procedure result sets</title>
</head>
<body id="rzaikspresultsets"><a name="rzaikspresultsets"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Stored procedure result sets</h1>
<div><p>Define scrollable SQL stored procedure result sets.</p>
<div class="section">An application can now have scrollable SQL stored procedure result
sets when running to a V5R3 (or later) iSeries™ server. To take advantage of
this support, make the following two changes. </div>
<ol><li><span>Create the stored procedure with the cursor defined as scrollable. </span><ol type="a"><li class="substepexpand"><span>This is done by adding the SCROLL keyword into the CREATE PROCEDURE.</span> In the following two examples, the first stored procedure returns
a scrollable result set while the second one does not. <ul><li><pre>CREATE PROCEDURE MYLIB.SCROLLSP ( ) RESULT SETS 1 LANGUAGE SQL
sqlproc: begin
DECLARE CUR1 SCROLL CURSOR FOR
SELECT * FROM QIWS.QCUSTCDT;
OPEN CUR1;
SET RESULT SETS CURSOR CUR1;
end </pre>
</li>
<li><pre>CREATE PROCEDURE MYLIB.NOSCROLLSP ( ) RESULT SETS 1 LANGUAGE SQL
sqlproc: begin
DECLARE CUR1 CURSOR FOR
SELECT * FROM QIWS.QCUSTCDT;
OPEN CUR1;
SET RESULT SETS CURSOR CUR1;
end</pre>
</li>
</ul>
</li>
</ol>
</li>
<li><span>Code the application using ODBC to ask for a scrollable cursor
type. </span><ol type="a"><li class="substepexpand"><span>Call the SQLSetStmtAttr API. </span></li>
<li class="substepexpand"><span>Set the SQL_ATTR_CURSOR_TYPE option to SQL_CURSOR_DYNAMIC. </span> <p>If an attempt is made to scroll backwards with a stored procedure
that did not specify a scrollable cursor, several different problems can occur.
In most cases an error is returned from the server indicating scrolling is
invalid, and in some cases incorrect data is returned.</p>
<p>Even if the stored
procedure returns multiple result sets, you can only use one cursor type.
ODBC either returns an error or ignores the cursor type when a different
cursor type is specified for the second result set. To use a scrollable result
set as one of the result sets, the application needs to set the cursor type
to be scrollable as defined above.</p>
<p>Any attempts to use an updateable
cursor with a stored procedure is ignored. Stored procedure result sets are
read-only.</p>
<p>Cursor sensitivity may not be honored with stored procedure
result sets. Cursor sensitivity is controlled by the way the server cursor
is defined when creating the procedure.</p>
</li>
</ol>
</li>
</ol>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaikodbcstoredproc.htm" title="Stored procedures commonly are used in client/server applications, especially in the area of online transaction processing (OLTP), since they can provide performance, transaction-integrity and security benefits.">Stored procedures</a></div>
</div>
</div>
</body>
</html>