279 lines
15 KiB
HTML
279 lines
15 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="SQLBindParam - Bind a buffer to a parameter marker" />
|
|
<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="rzadpfnbndpa" />
|
|
<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>SQLBindParam - Bind a buffer to a parameter marker</title>
|
|
</head>
|
|
<body id="rzadpfnbndpa"><a name="rzadpfnbndpa"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLBindParam - Bind a buffer to a parameter marker</h1>
|
|
<div><div class="section"></div>
|
|
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLBindParam()</samp> has
|
|
been deprecated and replaced by <a href="rzadpfnbndpm.htm#rzadpfnbndpm"><samp class="codeph">SQLBindParameter()</samp></a>.
|
|
Although this version of DB2<sup>®</sup> UDB CLI continues to support <samp class="codeph">SQLBindParam()</samp>,
|
|
it is recommended that you begin using <samp class="codeph">SQLBindParameter()</samp> in
|
|
your DB2 UDB
|
|
CLI programs so that they conform to the latest standards. </p>
|
|
<p><samp class="codeph">SQLBindParam()</samp> binds
|
|
an application variable to a parameter marker in an SQL statement. This function
|
|
can also be used to bind an application variable to a parameter of a stored
|
|
procedure CALL statement where the parameter can be input or output.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLBindParam (SQLHSTMT hstmt,
|
|
SQLSMALLINT ipar,
|
|
SQLSMALLINT fCType,
|
|
SQLSMALLINT fSqlType,
|
|
SQLINTEGER cbParamDef,
|
|
SQLSMALLINT ibScale,
|
|
SQLPOINTER rgbValue,
|
|
SQLINTEGER *pcbValue);</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. SQLBindParam arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="20%" id="d0e64">Data type</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e66">Argument</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e68">Use</th>
|
|
<th align="left" valign="bottom" width="40%" id="d0e70">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLHSTMT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>hstmt</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">Statement handle.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLINTEGER *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>pcbValue</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input (deferred), <span>or output (deferred),
|
|
or both</span></td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">A variable whose value is interpreted when
|
|
the statement is processed: <ul><li>If a null value is used as the parameter, <em>pcbValue</em> must contain
|
|
the value SQL_NULL_DATA.</li>
|
|
<li>If the dynamic argument is supplied at execute-time by calling <samp class="codeph">ParamData()</samp> and <samp class="codeph">PutData()</samp>, <em>pcbValue</em> must
|
|
contain the value SQL_DATA_AT_EXEC.</li>
|
|
<li>If <em>fcType</em> is SQL_CHAR and the data in <em>rgbValue</em> contains
|
|
a null-terminated string, <em>pcbValue</em> must either contain the length of
|
|
the data in <em>rgbValue</em> or contain the value SQL_NTS.</li>
|
|
<li>If <em>fcType</em> is SQL_CHAR and the data in <em>rgbValue</em> is not null-terminated, <em>pcbValue</em> must
|
|
contain the length of the data in <em>rgbValue</em>.</li>
|
|
<li>If <em>fcType</em> is an LOB type, <em>pcbValue</em> must
|
|
contain the length of the data in <em>rgbValue</em>. This length value must
|
|
be specified in bytes, not the number of double byte characters.</li>
|
|
<li>Otherwise, <em>pcbValue</em> must be zero.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLINTEGER</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>cbParamDef</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">Precision of the corresponding parameter
|
|
marker. <ul><li> If <em>fSqlType</em> denotes a single-byte character string (for example, <span>SQL_CHAR</span>),
|
|
this is the maximum length in bytes sent for this parameter. This length includes
|
|
the null-termination character.</li>
|
|
<li>If <em>fSqlType</em> denotes a double-byte character string (for example, <span>SQL_GRAPHIC</span>),
|
|
this is the maximum length in double-byte characters for this parameter.</li>
|
|
<li>If <em>fSqlType</em> denotes <span>SQL_DECIMAL or SQL_NUMERIC</span>, this is
|
|
the maximum decimal precision.</li>
|
|
<li>Otherwise, this argument is unused.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLPOINTER</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>rgbValue</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 "> <p>Input (deferred)<br />
|
|
or<br />
|
|
output (deferred)</p>
|
|
</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">At processing time, if <em>pcbValue</em> does
|
|
not contain SQL_NULL_DATA or SQL_DATA_AT_EXEC, then <em>rgbValue</em> points
|
|
to a buffer that contains the actual data for the parameter. <p>If <em>pcbValue</em> contains
|
|
SQL_DATA_AT_EXEC, then <em>rgbValue</em> is an application-defined 32-bit value
|
|
that is associated with this parameter. This 32-bit value is returned to the
|
|
application through a later <samp class="codeph">SQLParamData()</samp> call.</p>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>fCType</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">Application data type of the parameter. The
|
|
following types are supported: <ul><li>SQL_BIGINT</li>
|
|
<li>SQL_BINARY</li>
|
|
<li>SQL_BLOB</li>
|
|
<li>SQL_BLOB_LOCATOR</li>
|
|
<li>SQL_CHAR</li>
|
|
<li>SQL_CLOB</li>
|
|
<li>SQL_CLOB_LOCATOR</li>
|
|
<li>SQL_DATETIME</li>
|
|
<li>SQL_DBCLOB</li>
|
|
<li>SQL_DBCLOB_LOCATOR</li>
|
|
<li>SQL_DECIMAL</li>
|
|
<li>SQL_DOUBLE</li>
|
|
<li>SQL_FLOAT</li>
|
|
<li>SQL_GRAPHIC</li>
|
|
<li>SQL_INTEGER</li>
|
|
<li>SQL_NUMERIC</li>
|
|
<li>SQL_REAL</li>
|
|
<li>SQL_SMALLINT</li>
|
|
<li>SQL_TYPE_DATE</li>
|
|
<li>SQL_TYPE_TIME</li>
|
|
<li>SQL_TYPE_TIMESTAMP</li>
|
|
<li>SQL_VARBINARY</li>
|
|
<li>SQL_VARCHAR</li>
|
|
<li>SQL_VARGRAPHIC</li>
|
|
<li>SQL_WCHAR </li>
|
|
<li>SQL_WVARCHAR </li>
|
|
</ul>
|
|
<p>Specifying <span>SQL_DEFAULT</span> causes data to be transferred from
|
|
its default application data type to the type indicated in <em>fSqlType</em>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>fSqlType</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">SQL data type of the parameter. The supported
|
|
types are: <ul><li>SQL_BIGINT</li>
|
|
<li>SQL_BINARY</li>
|
|
<li>SQL_BLOB</li>
|
|
<li>SQL_BLOB_LOCATOR</li>
|
|
<li>SQL_CHAR</li>
|
|
<li>SQL_CLOB</li>
|
|
<li>SQL_CLOB_LOCATOR</li>
|
|
<li>SQL_DATETIME</li>
|
|
<li>SQL_DBCLOB</li>
|
|
<li>SQL_DBCLOB_LOCATOR</li>
|
|
<li>SQL_DECIMAL</li>
|
|
<li>SQL_DOUBLE</li>
|
|
<li>SQL_FLOAT</li>
|
|
<li>SQL_GRAPHIC</li>
|
|
<li>SQL_INTEGER</li>
|
|
<li>SQL_NUMERIC</li>
|
|
<li>SQL_REAL</li>
|
|
<li>SQL_SMALLINT</li>
|
|
<li>SQL_TYPE_DATE</li>
|
|
<li>SQL_TYPE_TIME</li>
|
|
<li>SQL_TYPE_TIMESTAMP</li>
|
|
<li>SQL_VARBINARY</li>
|
|
<li>SQL_VARCHAR</li>
|
|
<li>SQL_VARGRAPHIC</li>
|
|
<li>SQL_WCHAR </li>
|
|
<li>SQL_WVARCHAR </li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>ibScale</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">Scale of the corresponding parameter if <em>fSqlType</em> is
|
|
SQL_DECIMAL or <span>SQL_NUMERIC</span>. If <em>fSqlType</em> is SQL_TIMESTAMP,
|
|
this is the number of digits to the right of the decimal point in the character
|
|
representation of a timestamp (for example, the scale of yyyy-mm-dd hh:mm:ss.fff
|
|
is 3). <p>Other than for the <em>fSqlType</em> values mentioned here, <em>ibScale</em> is
|
|
unused.</p>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e64 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e66 "><em>ipar</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e70 ">Parameter marker number, ordered sequentially
|
|
left to right, starting at 1.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Usage</h4><p>When <samp class="codeph">SQLBindParam()</samp> is used
|
|
to bind an application variable to an output parameter for a stored procedure, DB2 UDB
|
|
CLI provides some performance enhancement if the <em>rgbValue</em> buffer is
|
|
placed consecutively in memory after the <em>pcbValue</em> buffer.</p>
|
|
</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>
|
|
</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 2. SQLBindParam SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="bottom" width="25%" id="d0e438">SQLSTATE</th>
|
|
<th align="left" valign="bottom" width="25%" id="d0e440">Description</th>
|
|
<th align="left" valign="bottom" width="50%" id="d0e442">Explanation</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>07</strong>006</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Restricted data type attribute violation</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Same as <samp class="codeph">SQLSetParam()</samp>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>40</strong>003 <strong>*</strong></td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Statement completion unknown</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">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="d0e438 "><strong>58</strong>004</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">System error</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Unrecoverable system error.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>001</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Memory allocation failure</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">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="d0e438 "><strong>HY</strong>003</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Program type out of range</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Same as <samp class="codeph">SQLSetParam()</samp>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>004</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">SQL data type out of range</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Same as <samp class="codeph">SQLSetParam()</samp>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>009</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Argument value that is not valid</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Both <em>rgbValue</em> and <em>pcbValue</em> are
|
|
null pointers, or <em>ipar</em> is less than one.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>010</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Function sequence error</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">Function is called after <samp class="codeph">SQLExecute()</samp> or <samp class="codeph">SQLExecDirect()</samp> has
|
|
returned SQL_NEED_DATA, but data has not been sent for all <em>data-at-execution</em> parameters.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>013 <strong>*</strong></td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Memory management problem</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">The driver is unable to access memory required
|
|
to support the processing or completion of the function.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="25%" headers="d0e438 "><strong>HY</strong>014</td>
|
|
<td align="left" valign="top" width="25%" headers="d0e440 ">Too many handles</td>
|
|
<td align="left" valign="top" width="50%" headers="d0e442 ">The maximum number of handles has been allocated.</td>
|
|
</tr>
|
|
<tr><td valign="top" width="25%" headers="d0e438 "><strong>HY</strong>021</td>
|
|
<td valign="top" width="25%" headers="d0e440 ">Internal descriptor that is not valid</td>
|
|
<td valign="top" width="50%" headers="d0e442 ">The internal descriptor cannot be addressed or allocated,
|
|
or it contains a value that is not valid.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</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> |