ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmsthsetrs.htm

172 lines
11 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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 xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" 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. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<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="keywords" content="SET RESULT SETS statement, SET RESULT SETS,
SQL statements, in SET RESULT SETS statement, WITH RETURN clause, cursor-name,
ARRAY clause, host-structure-array, FOR ROWS clause, NONE clause" />
<title>SET RESULT SETS</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="hsetrs"></a>
<h2 id="hsetrs"><a href="rbafzmst02.htm#ToC_1327">SET RESULT SETS</a></h2><a id="idx3192" name="idx3192"></a><a id="idx3193" name="idx3193"></a>
<a name="setrs"></a>
<p id="setrs">The SET RESULT SETS statement the result sets that can be returned
from an external procedure when the procedure is called by a iSeries Access Family client,
the SQL Call Level Interface, or when accessed from a remote system using DRDA&reg;.</p>
<a name="wq1780"></a>
<h3 id="wq1780"><a href="rbafzmst02.htm#ToC_1328">Invocation</a></h3>
<p>This statement can only be embedded in an application program. It is an
executable statement that cannot be dynamically prepared. It is not allowed
in a Java&trade; or REXX procedure.</p>
<a name="wq1781"></a>
<h3 id="wq1781"><a href="rbafzmst02.htm#ToC_1329">Authorization</a></h3>
<p>None required.</p>
<a name="wq1782"></a>
<h3 id="wq1782"><a href="rbafzmst02.htm#ToC_1330">Syntax</a></h3>
<a href="rbafzmsthsetrs.htm#setres"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn390.htm"
border="0" /></span><a href="#skipsyn-389"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a> .-TO CALLER-.
.-WITH RETURN--+-----------+-.
| '-TO CLIENT-' |
>>-SET RESULT SETS--+----------------------------+-------------->
.-,----------------------------------------------------.
V |
>--+---+-ARRAY--<span class="italic">host-structure-array</span>--FOR--<span><span class="italic">variable</span></span>--ROWS-+-+-+->&lt;
| '-CURSOR--<span class="italic">cursor-name</span>------------------------------' |
'-NONE-----------------------------------------------------'
</pre>
<a name="skipsyn-389" id="skipsyn-389"></a>
<a name="setres"></a>
<h3 id="setres"><a href="rbafzmst02.htm#ToC_1331">Description</a></h3>
<dl class="parml">
<dt class="bold">WITH RETURN </dt><a id="idx3194" name="idx3194"></a>
<dd>Specifies that the result table of the cursor is intended to be used
as a result set that will be returned from a procedure.
<p>For non-scrollable
cursors, the result set consists of all rows from the current cursor position
to the end of the result table. For scrollable cursors, the result set consists
of all rows of the result table.</p>
<dl class="parml">
<dt class="bold">TO CALLER</dt>
<dd>Specifies that the cursor can return a result set to the caller of the
procedure. For example, if the caller is a client application, the result
set is returned to the client application.
</dd>
<dt class="bold">TO CLIENT</dt>
<dd>Specifies that the cursor can return a result set to the client application.
This cursor is invisible to any intermediate nested procedures. If a function
called the procedure either directly or indirectly, result sets cannot be
returned to the client and the cursor will be closed after the procedure finishes.
</dd>
</dl>
</dd>
<dt class="bold">CURSOR <span class="italic">cursor-name</span> </dt><a id="idx3195" name="idx3195"></a>
<dd>Identifies a cursor to be used to define a result set that can be returned
from a procedure. The <span class="italic">cursor-name</span> must identify a
declared cursor as explained in <a href="rbafzmsth2clcu.htm#deccur">Description</a> for the
DECLARE CURSOR statement. When the SET RESULT SETS statement is executed,
the cursor must be in the open state.
</dd>
<dt class="bold">ARRAY <span class="italic">host-structure-array</span> </dt><a id="idx3196" name="idx3196"></a><a id="idx3197" name="idx3197"></a>
<dd><span class="italic">host-structure-array</span> identifies an array of
host structures defined in accordance with the rules for declaring host structures.
The array cannot contain a C NUL-terminated host variable.
<p>The first structure
in the array corresponds to the first row of the result set, the second structure
in the array corresponds to the second row of the result set, and so on. In
addition, the first value in the row corresponds to the first item in the
structure, the second value in the row corresponds to the second item in the
structure, and so on.</p>
<p>LOBs cannot be returned in an array when using DRDA.</p>
<p>Only one array can be specified in a SET RESULT SETS statement.</p>
</dd>
<dt class="bold">FOR <span class="italic">variable</span> ROWS <a id="idx3198" name="idx3198"></a></dt>
<dd>Specifies the number of rows in the result set. The <span class="italic">variable</span> must be a numeric variable with zero scale, and it must not
include an indicator variable. The number of rows specified must be in the
range of 0 to 32767 and must be less than or equal to the dimension of the
host structure array.
</dd>
<dt class="bold">NONE </dt><a id="idx3199" name="idx3199"></a>
<dd>Specifies that no result sets will be returned. Cursors left open when
the procedure ends will not be returned.
</dd>
</dl>
<a name="wq1783"></a>
<h3 id="wq1783"><a href="rbafzmst02.htm#ToC_1332">Notes</a></h3>
<p>Result sets are only returned if the procedure is directly called
or if the procedure is a RETURN TO CLIENT procedure and is indirectly called
from ODBC, JDBC, OLE DB, .NET, the SQL Call Level Interface, or the iSeries Access Family Optimized
SQL API. For more information about result sets, see <a href="rbafzmstcallsta.htm#callrs">Result sets from procedures</a> and <a href="rbafzmsth2clcu.htm#withreturn">WITH RETURN clause</a>.</p>
<p><span class="bold">External procedures:</span> There are three ways to return
result sets from an external procedure: </p>
<ul>
<li>If a SET RESULT SETS statement is executed in the procedure, the SET RESULT
SETS statement identifies the result sets. The result sets are returned in
the order specified on the SET RESULT SETS statement.</li>
<li>If a SET RESULT SETS statement is not executed in the procedure,
<ul>
<li>If no cursors have specified a WITH RETURN clause, each cursor that the
procedure opens and leaves open when it returns identifies a result set. The
result sets are returned in the order in which the cursors are opened.</li>
<li>If any cursors have specified a WITH RETURN clause, each cursor that is
defined with the WITH RETURN clause that the procedure opens and leaves open
when it returns identifies a result set. The result sets are returned in the
order in which the cursors are opened.</li></ul></li></ul><p class="indatacontent">When a result set is returned using an open cursor, the rows are returned
starting with the current cursor position.</p>
<p> The RESULT SETS clause should be specified on the ALTER PROCEDURE
(External), CREATE PROCEDURE (External) statement, or DECLARE PROCEDURE statement
to return result sets from a procedure. The maximum number of result sets
returned cannot be larger than the number specified on the ALTER PROCEDURE
(External), CREATE PROCEDURE (External) statement, or DECLARE PROCEDURE statement.</p>
<p><span class="bold">SQL procedures:</span> In order to return result sets from
an SQL procedure, the procedure must be created with the RESULT SETS clause.
Each cursor that is defined with the WITH RETURN clause that the procedure
opens and leaves open when it returns identifies a result set. </p>
<ul>
<li>If a SET RESULT SETS statement is executed in the procedure, the SET RESULT
SETS statement identifies which of these result sets to return. The result
sets are returned in the order specified on the SET RESULT SETS statement.</li>
<li>If a SET RESULT SETS statement is not executed in the procedure the result
sets are returned in the order in which the cursors are opened.</li></ul><p class="indatacontent">When a result set is returned using an open cursor, the rows are returned
starting with the current cursor position.</p>
<p> The RESULT SETS clause must be specified on the CREATE PROCEDURE (SQL)
statement to return any result sets from an SQL procedure. The maximum number
of result sets returned cannot be larger than the number specified on the
CREATE PROCEDURE statement.</p>
<a name="wq1784"></a>
<h3 id="wq1784"><a href="rbafzmst02.htm#ToC_1333">Example</a></h3>
<p>The following SET RESULT SETS statement specifies cursor X as the result
set that will be returned when the procedure is called. For more information
and complete examples showing the use of result sets from ODBC clients, see
the <a href="../rzahg/rzahgicia.htm">iSeries Access Family</a> category in the iSeries Information Center. </p>
<pre class="xmp"> EXEC SQL <span class="bold">SET RESULT SETS CURSOR</span> X;</pre><a id="idx3200" name="idx3200"></a><a id="idx3201" name="idx3201"></a>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstsetpath.htm">Previous Page</a> | <a href="rbafzmstsetschema.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
<a href="rbafzmstindex.htm#index">Index</a> ]
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>