143 lines
8.6 KiB
HTML
143 lines
8.6 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="SQLAllocStmt - Allocate a statement handle" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.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="rzadpfnastmt" />
|
|
<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>SQLAllocStmt - Allocate a statement handle</title>
|
|
</head>
|
|
<body id="rzadpfnastmt"><a name="rzadpfnastmt"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLAllocStmt - Allocate a statement handle</h1>
|
|
<div><div class="section"></div>
|
|
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLAllocStmt()</samp> allocates
|
|
a new statement handle and associates it with the connection specified by
|
|
the connection handle. There is no defined limit on the number of statement
|
|
handles that can be allocated at any one time.</p>
|
|
<p><samp class="codeph">SQLConnect()</samp> must
|
|
be called before calling this function.</p>
|
|
<p>This function must be called
|
|
before <samp class="codeph">SQLBindParam()</samp>, <samp class="codeph">SQLPrepare(), SQLExecute(),
|
|
SQLExecDirect()</samp>, or any other function that has a statement handle
|
|
as one of its input arguments.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4> <pre>SQLRETURN SQLAllocStmt (SQLHDBC hdbc,
|
|
SQLHSTMT *phstmt);</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. SQLAllocStmt arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="20%" id="d0e67">Data type</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e69">Argument</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e71">Use</th>
|
|
<th align="left" valign="bottom" width="40%" id="d0e73">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e67 ">SQLHDBC</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e69 "><em>hdbc</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e71 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e73 ">Connection handle</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e67 ">SQLHSTMT *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e69 "><em>phstmt</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e71 ">Output</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e73 ">Pointer to statement handle</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Usage</h4> <p>DB2<sup>®</sup> UDB CLI uses each statement handle to
|
|
relate all the descriptors, result values, cursor information, and status
|
|
information to the SQL statement processed. Although each SQL statement must
|
|
have a statement handle, you can reuse the handles for different statements.</p>
|
|
<p>A
|
|
call to this function requires that <em>hdbc</em> references an active database
|
|
connection.</p>
|
|
<p>To process a positioned update or delete, the application
|
|
must use different statement handles for the SELECT statement and the UPDATE
|
|
or DELETE statement.</p>
|
|
<p>If the input pointer to the statement handle (<em>phstmt</em>)
|
|
points to a valid statement handle allocated by a previous call to <samp class="codeph">SQLAllocStmt()</samp>,
|
|
then the original value is overwritten as a result of this call. This is an
|
|
application programming error and is not detected by DB2 UDB CLI.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Return codes</h4> <ul><li>SQL_SUCCESS</li>
|
|
<li>SQL_ERROR</li>
|
|
<li>SQL_INVALID_HANDLE</li>
|
|
</ul>
|
|
<p>If SQL_ERROR is returned, the <em>phstmt</em> argument is set to SQL_NULL_HSTMT.
|
|
The application should call <samp class="codeph">SQLError()</samp> with the same <em>hdbc</em> and
|
|
with the <em>hstmt</em> argument set to SQL_NULL_HSTMT.</p>
|
|
</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 2. SQLAllocStmt SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="bottom" width="25%" id="d0e167">SQLSTATE</th>
|
|
<th align="left" valign="bottom" width="25%" id="d0e169">Description</th>
|
|
<th align="left" valign="bottom" width="50%" id="d0e171">Explanation</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e167 "><strong>08</strong>003</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">Connection not open</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 ">The connection specified by the <em>hdbc</em> argument
|
|
is not open. The connection must be established successfully (and the connection
|
|
must be open) for the driver to allocate an <em>hstmt</em>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e167 "><strong>40</strong>003 <strong>*</strong></td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">Statement completion unknown</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 ">The communication link between the CLI and
|
|
the data source fails before the function completes processing.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e167 "><strong>58</strong>004</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">System error</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 ">Unrecoverable system error.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e167 "><strong>HY</strong>001</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">Memory allocation failure</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 ">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="d0e167 "><strong>HY</strong>009</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">Argument value that is not valid</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 "><em>phstmt</em> is a null pointer.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e167 "><strong>HY</strong>013 <strong>*</strong></td>
|
|
<td align="left" valign="top" width="25%" headers="d0e169 ">Memory management problem</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e171 ">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">Example</h4></div>
|
|
<div class="example" id="rzadpfnastmt__xmastmt"><a name="rzadpfnastmt__xmastmt"><!-- --></a><p>Refer to the example in <a href="rzadpfnfetch.htm">SQLFetch - Fetch next row</a>.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">References</h4><ul><li><a href="rzadpfnconn.htm#rzadpfnconn">SQLConnect - Connect to a data source</a></li>
|
|
<li><a href="rzadpfnfstmt.htm#rzadpfnfstmt">SQLFreeStmt - Free (or reset) a statement handle</a></li>
|
|
<li><a href="rzadpfngstmo.htm#rzadpfngstmo">SQLGetStmtOption - Return current setting of a statement option</a></li>
|
|
<li><a href="rzadpfnsstmo.htm#rzadpfnsstmo">SQLSetStmtOption - Set statement option</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>
|
|
</body>
|
|
</html> |