186 lines
11 KiB
HTML
186 lines
11 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="reference" />
|
|
<meta name="DC.Title" content="SQLFetchScroll - Fetch from a scrollable cursor" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadpfnsstma.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="rzadpfetchsc" />
|
|
<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>SQLFetchScroll - Fetch from a scrollable cursor</title>
|
|
</head>
|
|
<body id="rzadpfetchsc"><a name="rzadpfetchsc"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLFetchScroll - Fetch from a scrollable cursor</h1>
|
|
<div><div class="section"></div>
|
|
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLFetchScroll()</samp> positions the cursor
|
|
based on the requested orientation, then retrieves any bound columns.</p>
|
|
<p><samp class="codeph">SQLFetchScroll()</samp> can
|
|
be used to receive the data directly into variables you specify with <samp class="codeph">SQLBindCol()</samp>,
|
|
or the columns can be received individually after the fetch, by calling <samp class="codeph">SQLGetData()</samp>.
|
|
Data conversion is also performed when <samp class="codeph">SQLFetchScroll()</samp> is
|
|
called, if conversion is indicated when the column is bound.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLFetchScroll (SQLHSTMT hstmt,
|
|
SQLSMALLINT fOrient,
|
|
SQLINTEGER fOffset);</pre>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLFetchScroll arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="20%" id="d0e62">Data type</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e64">Argument</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e66">Use</th>
|
|
<th align="left" valign="bottom" width="40%" id="d0e68">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e62 ">SQLHSTMT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e64 "><em>hstmt</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e68 ">Statement handle.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e62 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e64 "><em>fOrient</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e68 ">Fetch orientation. See <a href="#rzadpfetchsc__tfetch">Table 2</a> for
|
|
possible values.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e62 ">SQLINTEGER</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e64 "><em>fOffset</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e68 ">Row offset for relative positioning.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Usage</h4><p><samp class="codeph">SQLFetchScroll()</samp> can only
|
|
be called if the most recently processed statement on <em>hstmt</em> is a SELECT.</p>
|
|
<p><samp class="codeph">SQLFetchScroll()</samp> acts
|
|
like <samp class="codeph">SQLFetch()</samp>, except the <em>fOrient</em> parameter positions
|
|
the cursor before any data is retrieved. The cursor must be a scrollable cursor
|
|
for <samp class="codeph">SQLFetchScroll()</samp> to use any orientation other than SQL_FETCH_NEXT.
|
|
See <a href="rzadpfnsstma.htm#rzadpfnsstma">SQLSetStmtAttr - Set a statement attribute</a> for information about
|
|
setting the SQL_ATTR_CURSOR_SCROLLABLE attribute.</p>
|
|
<p>When using this function
|
|
to retrieve rows from an SQL procedure result set, only the SQL_FETCH_NEXT
|
|
orientation is supported.</p>
|
|
<p><img src="./delta.gif" alt="Start of change" /><samp class="codeph">SQLFetchScroll()</samp> supports
|
|
array fetch, an alternative to the array fetch support provided by <samp class="codeph">SQLExtendedFetch()</samp>.
|
|
See the <samp class="codeph">SQLExtendedFetch()</samp> topic for details on array fetch.<img src="./deltaend.gif" alt="End of change" /></p>
|
|
<div class="p">The information returned in the <em>RowCountPtr</em> and <em>RowStatusArray</em> parameters
|
|
of <samp class="codeph">SQLExtendedFetch()</samp> are handled by <samp class="codeph">SQLFetchScroll()</samp> as
|
|
follows:<ul><li><em>RowCountPtr</em>: <samp class="codeph">SQLFetchScroll()</samp> returns the number
|
|
of rows fetched in the buffer pointed to by the SQL_ATTR_ROWS_FETCHED_PTR
|
|
statement attribute.</li>
|
|
<li><em>RowStatusArray</em>: <samp class="codeph">SQLFetchScroll()</samp> returns the array
|
|
of statuses for each row in the buffer pointed to by the SQL_ATTR_ROW_STATUS_PTR
|
|
statement attribute.</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><a name="rzadpfetchsc__tfetch"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfetchsc__tfetch" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. Statement
|
|
attributes</caption><thead align="left"><tr><th align="left" valign="top" width="50%" id="d0e180"><em>fOrient</em></th>
|
|
<th align="left" valign="top" width="50%" id="d0e183">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="50%" headers="d0e180 ">SQL_FETCH_FIRST</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e183 ">Move to the first row of the result set.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="50%" headers="d0e180 ">SQL_FETCH_LAST</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e183 ">Move to the last row of the result set.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="50%" headers="d0e180 ">SQL_FETCH_NEXT</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e183 ">Move to the row following the current cursor
|
|
position.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="50%" headers="d0e180 ">SQL_FETCH_PRIOR</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e183 ">Move to the row preceding the current cursor
|
|
position.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="50%" headers="d0e180 ">SQL_FETCH_RELATIVE</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e183 ">If <em>fOffset</em> is: <ul><li>Positive, advance the cursor that number of rows.</li>
|
|
<li>Negative, back up the cursor that number of rows.</li>
|
|
<li>Zero, do not move the cursor.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Return codes</h4><ul><li>SQL_SUCCESS</li>
|
|
<li>SQL_SUCCESS_WITH_INFO</li>
|
|
<li>SQL_ERROR</li>
|
|
<li>SQL_INVALID_HANDLE</li>
|
|
<li>SQL_NO_DATA_FOUND</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Diagnostics</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 3. SQLFetchScroll SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e249">SQLSTATE</th>
|
|
<th align="left" valign="top" width="25%" id="d0e251">Description</th>
|
|
<th align="left" valign="top" width="50%" id="d0e253">Explanation</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e249 "><strong>01</strong>004</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e251 ">Data truncated</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e253 ">The data returned for one or more columns
|
|
is truncated. String values are right truncated. (SQL_SUCCESS_WITH_INFO is
|
|
returned if no error occurred.)</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e249 "><strong>HY</strong>001</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e251 ">Memory allocation failure</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e253 ">The driver is unable to allocate memory required
|
|
to support the processing or completion of the function.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e249 "><strong>HY</strong>009</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e251 ">Argument value that is not valid</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e253 ">Orientation that is not valid.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e249 "><strong>HY</strong>010</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e251 ">Function sequence error</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e253 ">The specified <em>hstmt</em> is not in an processed
|
|
state. The function is called without first calling SQLExecute or SQLExecDirect.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e249 "><strong>HY</strong>013 <strong>*</strong></td>
|
|
<td align="left" valign="top" width="25%" headers="d0e251 ">Memory management problem</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e253 ">The driver is unable to access memory required
|
|
to support the processing or completion of the function.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">References</h4><ul><li><a href="rzadpfnbindc.htm#rzadpfnbindc">SQLBindCol - Bind a column to an application variable</a></li>
|
|
<li><a href="rzadpfnexec.htm#rzadpfnexec">SQLExecute - Execute a statement</a></li>
|
|
<li><a href="rzadpfnexecd.htm#rzadpfnexecd">SQLExecDirect - Execute a statement directly</a></li>
|
|
<li><a href="rzadpfnexfet.htm">SQLExtendedFetch - Fetch array of rows</a></li>
|
|
<li><a href="rzadpfngcol.htm#rzadpfngcol">SQLGetCol - Retrieve one column of a row of the result set</a></li>
|
|
<li><a href="rzadpfnfetch.htm#rzadpfnfetch">SQLFetch - Fetch next row</a></li>
|
|
<li><a href="rzadpfnsstma.htm">SQLSetStmtAttr - Set a statement attribute</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzadphdapi.htm" title="This topic provides a description of each CLI function.">DB2 UDB CLI functions</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="rzadpfnsstma.htm">SQLSetStmtAttr - Set a statement attribute</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |