ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafymrfetch.htm

89 lines
6.1 KiB
HTML
Raw Permalink 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 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="reference" />
<meta name="DC.Title" content="Use the multiple-row FETCH statement" />
<meta name="abstract" content="The multiple-row FETCH statement can be used to retrieve multiple rows from a table or view with a single FETCH. The program controls the blocking of rows by the number of rows requested on the FETCH statement (OVRDBF has no effect)." />
<meta name="description" content="The multiple-row FETCH statement can be used to retrieve multiple rows from a table or view with a single FETCH. The program controls the blocking of rows by the number of rows requested on the FETCH statement (OVRDBF has no effect)." />
<meta name="DC.subject" content="FETCH statement, statements, FETCH, multiple-row, Override Database File (OVRDBF) command, command (CL), Override Database File (OVRDBF), OVRDBF (Override Database File)" />
<meta name="keywords" content="FETCH statement, statements, FETCH, multiple-row, Override Database File (OVRDBF) command, command (CL), Override Database File (OVRDBF), OVRDBF (Override Database File)" />
<meta name="DC.Relation" scheme="URI" content="rbafycurs.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafymultifetch1.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafymultifetch2.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzajp/rzajpkickoff.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafymrfetch" />
<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>Use the multiple-row FETCH statement</title>
</head>
<body id="rbafymrfetch"><a name="rbafymrfetch"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use the multiple-row FETCH statement</h1>
<div><p>The multiple-row FETCH statement can be used to retrieve multiple
rows from a table or view with a single FETCH. The program controls the blocking
of rows by the number of rows requested on the FETCH statement (OVRDBF has
no effect).</p>
<div class="section"><p>The maximum number of rows that can be requested on a single fetch
call is 32767. Once the data is retrieved, the cursor is positioned on the
last row retrieved.</p>
</div>
<div class="section"><p>There are two ways to define the storage where fetched rows are
placed: a host structure array or a row storage area with an associated descriptor.
Both methods can be coded in all of the languages supported by the SQL precompilers,
with the exception of the host structure array in REXX.
Both forms of the multiple-row FETCH statement allow the application to code
a separate indicator array. The indicator array should contain one indicator
for each host variable that is null capable.</p>
</div>
<div class="section"><p>The multiple-row FETCH statement can be used with both serial
and scrollable cursors. The operations used to define, open, and close a cursor
for a multiple-row FETCH remain the same. Only the FETCH statement changes
to specify the number of rows to retrieve and the storage where the rows are
placed.</p>
</div>
<div class="section"><p>After each multiple-row FETCH, information is returned to the
program through the SQLCA. In addition to the SQLCODE and SQLSTATE fields,
the SQLERRD provides the following information:</p>
<ul><li>SQLERRD3 contains the number of rows retrieved on the multiple-row FETCH
statement. If SQLERRD3 is less than the number of rows requested, then an
error or end-of-data condition occurred.</li>
<li>SQLERRD4 contains the length of each row retrieved.</li>
<li>SQLERRD5 contains an indication that the last row in the table was fetched.
It can be used to detect the end-of-data condition in the table being fetched
when the cursor does not have immediate sensitivity to updates. Cursors which
do have immediate sensitivity to updates should continue fetching until an
SQLCODE +100 is received to detect an end-of-data condition.</li>
</ul>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbafymultifetch1.htm">Multiple-row FETCH using a host structure array</a></strong><br />
To use the multiple-row FETCH with the host structure array, the application must define a host structure array that can be used by SQL.</li>
<li class="ulchildlink"><strong><a href="rbafymultifetch2.htm">Multiple-row FETCH using a row storage area</a></strong><br />
The application must define a row storage area and an associated description area before the application can use a multiple-row FETCH with a row storage area. The row storage area is a host variable defined in the application program.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafycurs.htm" title="When SQL runs a select statement, the resulting rows comprise the result table. A cursor provides a way to access a result table.">Use a cursor</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../rzajp/rzajpkickoff.htm">Embedded SQL programming</a></div>
</div>
</div>
</body>
</html>