451 lines
32 KiB
HTML
451 lines
32 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="SQLBindParameter - Bind a parameter marker to a buffer" />
|
||
|
<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="rzadpfnbndpm" />
|
||
|
<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>SQLBindParameter - Bind a parameter marker to a buffer</title>
|
||
|
</head>
|
||
|
<body id="rzadpfnbndpm"><a name="rzadpfnbndpm"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">SQLBindParameter - Bind a parameter marker to a buffer</h1>
|
||
|
<div><div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLBindParameter()</samp> is
|
||
|
used to associate (bind) parameter markers in an SQL statement to application
|
||
|
variables. Data is transferred from the application to the Database Management
|
||
|
System (DBMS) when <samp class="codeph">SQLExecute()</samp> or <samp class="codeph">SQLExecDirect()</samp> is
|
||
|
called. Data conversion might occur as the data is transferred.</p>
|
||
|
<p>This
|
||
|
function must also be used to bind an application storage to a parameter of
|
||
|
a stored procedure CALL statement where the parameter can be input, output
|
||
|
or both. This function is essentially an extension of <samp class="codeph">SQLSetParam()</samp>.</p>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">Syntax</h4> <pre>SQLRETURN SQLBindParameter(SQLHSTMT StatementHandle,
|
||
|
SQLSMALLINT ParameterNumber,
|
||
|
SQLSMALLINT InputOutputType,
|
||
|
SQLSMALLINT ValueType,
|
||
|
SQLSMALLINT ParameterType,
|
||
|
SQLINTEGER ColumnSize,
|
||
|
SQLSMALLINT DecimalDigits,
|
||
|
SQLPOINTER ParameterValuePtr,
|
||
|
SQLINTEGER BufferLength,
|
||
|
SQLINTEGER *StrLen_or_IndPtr);</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. SQLBindParameter arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="25.186567164179102%" id="d0e56">Data type</th>
|
||
|
<th align="left" valign="bottom" width="21.26865671641791%" id="d0e58">Argument </th>
|
||
|
<th align="left" valign="bottom" width="10.820895522388058%" id="d0e60">Use </th>
|
||
|
<th align="left" valign="bottom" width="42.723880597014926%" id="d0e62">Description </th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody><tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLHSTMT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>StatementHandle</em> </td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">Statement handle.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLINTEGER </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>ColumnSize</em></td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">Precision of the corresponding parameter
|
||
|
marker. <ul><li>If <span class="synph"><span class="var">ParameterType</span></span> denotes a binary or single-byte
|
||
|
character string (for example, SQL_CHAR), this is the maximum length in bytes
|
||
|
for this parameter marker.</li>
|
||
|
<li>If <span class="synph"><span class="var">ParameterType</span></span> denotes a double-byte character
|
||
|
string (for example, SQL_GRAPHIC), this is the maximum length in double-byte
|
||
|
characters for this parameter.</li>
|
||
|
<li>If <span class="synph"><span class="var">ParameterType</span></span> denotes SQL_DECIMAL or SQL_NUMERIC,
|
||
|
this is the maximum decimal precision.</li>
|
||
|
<li>Otherwise, this argument is ignored.</li>
|
||
|
</ul>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLINTEGER *</td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>StrLen_or_IndPtr</em></td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input (deferred), output (deferred)</td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 "><p>If this is an input or input/output parameter,
|
||
|
this is the pointer to the location that contains (when the statement is processed)
|
||
|
the length of the parameter marker value stored at <span class="synph"><span class="var">ParameterValuePtr</span></span>.</p>
|
||
|
<p>To
|
||
|
specify a null value for a parameter marker, this storage location must contain
|
||
|
SQL_NULL_DATA.</p>
|
||
|
<p>If <span class="synph"><span class="var">ValueType</span></span> is SQL_C_CHAR,
|
||
|
this storage location must contain either the exact length of the data stored
|
||
|
at <span class="synph"><span class="var">ParameterValuePtr</span></span>, or SQL_NTS if the content
|
||
|
at <span class="synph"><span class="var">ParameterValuePtr</span></span> is null-terminated.</p>
|
||
|
<p>If <span class="synph"><span class="var">ValueType</span></span> indicates
|
||
|
LOB data, this storage location must contain the length of the data stored
|
||
|
at <em>ParameterValuePtr</em>. This length value must be specified in bytes,
|
||
|
not the number of double-byte characters.</p>
|
||
|
<p>If <span class="synph"><span class="var">ValueType</span></span> indicates
|
||
|
character data (explicitly, or implicitly using SQL_C_DEFAULT), and this pointer
|
||
|
is set to NULL, it is assumed that the application always provides a null-terminated
|
||
|
string in <span class="synph"><span class="var">ParameterValuePtr</span></span>. This also implies that
|
||
|
this parameter marker never has a null value.</p>
|
||
|
<p>If <span class="synph"><span class="var">ValueType</span></span> specifies
|
||
|
any form of double-byte character data, then StrLen_or_IndPtr must be the
|
||
|
number of double-byte characters, not the number of bytes. </p>
|
||
|
<p>When <samp class="codeph">SQLExecute()</samp> or <samp class="codeph">SQLExecDirect()</samp> is
|
||
|
called, and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> points to a value of
|
||
|
SQL_DATA_AT_EXEC, the data for the parameter is sent with <samp class="codeph">SQLPutData()</samp>.
|
||
|
This parameter is referred to as a <em>data-at-execution</em> parameter.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLINTEGER </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>BufferLength</em> </td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">Not used.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLPOINTER </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>ParameterValuePtr</em></td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 "><p>Input (deferred), or output
|
||
|
(deferred), or both</p>
|
||
|
</td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 "> <ul><li>On input (<span class="synph"><span class="var">InputOutputType</span></span> set to SQL_PARAM_INPUT,
|
||
|
or SQL_PARAM_INPUT_OUTPUT), the following situations are true: <p> At processing
|
||
|
time, if <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> does not contain SQL_NULL_DATA
|
||
|
or SQL_DATA_AT_EXEC, then <span class="synph"><span class="var">ParameterValuePtr</span></span> points
|
||
|
to a buffer that contains the actual data for the parameter.</p>
|
||
|
<p>If <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> contains
|
||
|
SQL_DATA_AT_EXEC, then <span class="synph"><span class="var">ParameterValuePtr</span></span> is an application-defined
|
||
|
32-bit value that is associated with this parameter. This 32-bit value is
|
||
|
returned to the application via a subsequent <samp class="codeph">SQLParamData()</samp> call.</p>
|
||
|
<p>If <samp class="codeph">SQLParamOptions()</samp> is
|
||
|
called to specify multiple values for the parameter, then <span class="synph"><span class="var">ParameterValuePtr</span></span> is
|
||
|
a pointer to an input buffer array of <span class="synph"><span class="var">BufferLength</span></span> bytes.</p>
|
||
|
</li>
|
||
|
<li>On output (<span class="synph"><span class="var">InputOutputType</span></span> set to SQL_PARAM_OUTPUT,
|
||
|
or SQL_PARAM_INPUT_OUTPUT), the following situations are true: <p> <span class="synph"><span class="var">ParameterValuePtr</span></span> points
|
||
|
to the buffer where the output parameter value of the stored procedure is
|
||
|
stored.</p>
|
||
|
<p>If <span class="synph"><span class="var">InputOutputType</span></span> is set to SQL_PARAM_OUTPUT,
|
||
|
and both <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> are
|
||
|
NULL pointers, then the output parameter value or the return value from the
|
||
|
stored procedure call is discarded.</p>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLSMALLINT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>DecimalDigits</em></td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">Scale of the corresponding parameter if <span class="synph"><span class="var">ParameterType</span></span> is
|
||
|
SQL_DECIMAL or SQL_NUMERIC. If <span class="synph"><span class="var">ParameterType</span></span> is
|
||
|
SQL_TYPE_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 <span class="synph"><span class="var">ParameterType</span></span> values
|
||
|
mentioned here, <span class="synph"><span class="var">DecimalDigits</span></span> is ignored.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLSMALLINT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>InputOutputType</em> </td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">The type of parameter. <span>The value of the
|
||
|
SQL_DESC_PARAMETER_TYPE field of the implementation parameter descriptor (IPD)
|
||
|
is also set to this argument.</span> The supported types are: <ul><li>SQL_PARAM_INPUT: The parameter marker is associated with an SQL statement
|
||
|
that is not a stored procedure CALL; or, it marks an input parameter of the
|
||
|
CALLed stored procedure. <p> When the statement is processed, the actual
|
||
|
data value for the parameter is sent to the server: the <em>ParameterValuePtr</em> buffer
|
||
|
must contain valid input data values; the <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> buffer
|
||
|
must contain the corresponding length value or SQL_NTS, SQL_NULL_DATA, or
|
||
|
(if the value should be sent via <samp class="codeph">SQLParamData()</samp> and <samp class="codeph">SQLPutData()</samp>)
|
||
|
SQL_DATA_AT_EXEC.</p>
|
||
|
</li>
|
||
|
<li>SQL_PARAM_INPUT_OUTPUT: The parameter marker is associated with an input/output
|
||
|
parameter of the CALLed stored procedure. <p>When the statement is processed,
|
||
|
actual data value for the parameter is sent to the server: the <em>ParameterValuePtr</em> buffer
|
||
|
must contain valid input data values; the <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> buffer
|
||
|
must contain the corresponding length value or SQL_NTS, SQL_NULL_DATA, or
|
||
|
(if the value should be sent via <samp class="codeph">SQLParamData()</samp> and <samp class="codeph">SQLPutData()</samp>)
|
||
|
SQL_DATA_AT_EXEC.</p>
|
||
|
</li>
|
||
|
<li>SQL_PARAM_OUTPUT: The parameter marker is associated with an output parameter
|
||
|
of the CALLed stored procedure or the return value of the stored procedure.
|
||
|
<p>After the statement is processed, data for the output parameter is returned
|
||
|
to the application buffer specified by <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span>,
|
||
|
unless both are NULL pointers, in which case the output data is discarded. <span>If
|
||
|
an output parameter does not have a return value then <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> is
|
||
|
set to SQL_NULL_DATA.</span></p>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLSMALLINT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>ParameterNumber</em> </td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">Parameter marker number, ordered sequentially
|
||
|
left to right, starting at 1.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLSMALLINT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>ParameterType </em></td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">SQL data type of the parameter.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="25.186567164179102%" headers="d0e56 ">SQLSMALLINT </td>
|
||
|
<td align="left" valign="top" width="21.26865671641791%" headers="d0e58 "><em>ValueType</em> </td>
|
||
|
<td align="left" valign="top" width="10.820895522388058%" headers="d0e60 ">Input </td>
|
||
|
<td align="left" valign="top" width="42.723880597014926%" headers="d0e62 ">C 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_WCHAR </li>
|
||
|
<li>SQL_WVARCHAR </li>
|
||
|
<li>SQL_WVARCHAR </li>
|
||
|
</ul>
|
||
|
<p>Specifying SQL_C_DEFAULT causes data to be transferred from its default
|
||
|
C data type to the type indicated in <span class="synph"><span class="var">ParameterType</span></span>.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">Usage</h4><p>A parameter marker is represented by a "?"
|
||
|
character in an SQL statement and is used to indicate a position in the statement
|
||
|
where an application supplied value is to be substituted when the statement
|
||
|
is processed. This value is obtained from an application variable.</p>
|
||
|
<p>The
|
||
|
application must bind a variable to each parameter marker in the SQL statement
|
||
|
before executing the SQL statement. For this function, <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> are
|
||
|
deferred arguments; the storage locations must be valid and contain input
|
||
|
data values when the statement is processed. This means either keeping the <samp class="codeph">SQLExecDirect()</samp> or <samp class="codeph">SQLExecute()</samp> call
|
||
|
in the same procedure scope as the <samp class="codeph">SQLBindParameter()</samp> calls,
|
||
|
or these storage locations must be dynamically allocated or declared statically
|
||
|
or globally.</p>
|
||
|
<p>Parameter markers are referred to by number (<span class="synph"><span class="var">ParameterNumber</span></span>)
|
||
|
and are numbered sequentially from left to right, starting at 1.</p>
|
||
|
<p>All
|
||
|
parameters bound by this function remain in effect until <samp class="codeph">SQLFreeStmt()</samp> is
|
||
|
called with either the SQL_DROP or SQL_RESET_PARAMS option, or until <samp class="codeph">SQLBindParameter()</samp> is
|
||
|
called again for the same parameter <span class="synph"><span class="var">ParameterNumber</span></span> number.</p>
|
||
|
<p>After
|
||
|
the SQL statement and the results have been processed, the application might
|
||
|
want to reuse the statement handle to process a different SQL statement. If
|
||
|
the parameter marker specifications are different (number of parameters, length
|
||
|
or type), then <samp class="codeph">SQLFreeStmt()</samp> should be called
|
||
|
with SQL_RESET_PARAMS to reset or clear the parameter bindings.</p>
|
||
|
<p>The
|
||
|
C buffer data type that is given by <span class="synph"><span class="var">ValueType</span></span> must
|
||
|
be compatible with the SQL data type that is indicated by <span class="synph"><span class="var">ParameterType</span></span>,
|
||
|
or an error occurs.</p>
|
||
|
<p>Because the data in the variables referenced by <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> is not verified until the statement is processed, data content or
|
||
|
format errors are not detected or reported until <samp class="codeph">SQLExecute()</samp> or <samp class="codeph">SQLExecDirect()</samp> is
|
||
|
called.</p>
|
||
|
<p><samp class="codeph">SQLBindParameter()</samp> essentially extends the
|
||
|
capability of the <samp class="codeph">SQLSetParam()</samp> function by providing a method
|
||
|
of specifying whether a parameter is input, input and output, or output. This
|
||
|
information is necessary for the proper handling of parameters for stored
|
||
|
procedures.</p>
|
||
|
<p>The <span class="synph"><span class="var">InputOutputType</span></span> argument specifies
|
||
|
the type of the parameter. All parameters in the SQL statements that do not
|
||
|
call procedures are input parameters. Parameters in stored procedure calls
|
||
|
can be input, input/output, or output parameters. Even though the DB2<sup>®</sup> stored procedure
|
||
|
argument convention typically implies that all procedure arguments are input/output,
|
||
|
the application programmer can still choose to specify more exactly the input
|
||
|
or output nature on the <samp class="codeph">SQLBindParameter()</samp> to follow a more
|
||
|
rigorous coding style. Also, note that these types should be consistent with
|
||
|
the parameter types specified when the stored procedure is registered with
|
||
|
the SQL CREATE PROCEDURE statement.</p>
|
||
|
<ul><li>If an application cannot determine the type of a parameter in a procedure
|
||
|
call, set <span class="synph"><span class="var">InputOutputType</span></span> to SQL_PARAM_INPUT; if
|
||
|
the data source returns a value for the parameter, DB2 UDB CLI discards it.</li>
|
||
|
<li>If an application has marked a parameter as SQL_PARAM_INPUT_OUTPUT or
|
||
|
SQL_PARAM_OUTPUT and the data source does not return a value, DB2 UDB CLI sets
|
||
|
the <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> buffer to SQL_NULL_DATA.</li>
|
||
|
<li>If an application marks a parameter as SQL_PARAM_OUTPUT, data for the
|
||
|
parameter is returned to the application after the CALL statement has been
|
||
|
processed. If the <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> arguments
|
||
|
are both null pointers, DB2 UDB CLI discards the output value. If the data source
|
||
|
does not return a value for an output parameter, DB2 UDB CLI sets the <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> buffer
|
||
|
to SQL_NULL_DATA.</li>
|
||
|
<li>For this function, both <span class="synph"><span class="var">ParameterValuePtr</span></span> and <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> are
|
||
|
deferred arguments. In the case where <span class="synph"><span class="var">InputOutputType</span></span> is
|
||
|
set to SQL_PARAM_INPUT or SQL_PARAM_INPUT_OUTPUT, the storage locations must
|
||
|
be valid and contain input data values when the statement is processed. This
|
||
|
means either keeping the <samp class="codeph">SQLExecDirect()</samp> or <samp class="codeph">SQLExecute()</samp> call
|
||
|
in the same procedure scope as the <samp class="codeph">SQLBindParameter()</samp> calls,
|
||
|
or, these storage locations must be dynamically allocated or statically /
|
||
|
globally declared. <p>Similarly, if <span class="synph"><span class="var">InputOutputType</span></span> is
|
||
|
set to SQL_PARAM_OUTPUT or SQL_PARAM_INPUT_OUTPUT, the ParameterValuePtr and
|
||
|
StrLen_or_IndPtr buffer locations must remain valid until the CALL statement
|
||
|
has been processed.</p>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div class="p">When <samp class="codeph">SQLBindParameter()</samp> is
|
||
|
used to bind an application variable to an output parameter for a stored procedure, DB2 UDB
|
||
|
CLI can provide some performance enhancement if the <span class="synph"><span class="var">ParameterValuePtr</span></span> buffer
|
||
|
is placed consecutively in memory after the <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> buffer.
|
||
|
For example: <pre> struct { SQLINTEGER StrLen_or_IndPtr;
|
||
|
SQLCHAR ParameterValuePtr[MAX_BUFFER];
|
||
|
} column;</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">Return codes</h4><div class="p"> <ul><li>SQL_SUCCESS</li>
|
||
|
<li>SQL_SUCCESS_WITH_INFO</li>
|
||
|
<li>SQL_ERROR</li>
|
||
|
<li>SQL_INVALID_HANDLE</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">Error conditions</h4>
|
||
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 2. SQLBindParameter SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="bottom" width="12.962962962962962%" id="d0e678">SQLSTATE </th>
|
||
|
<th align="left" valign="bottom" width="29.074074074074076%" id="d0e680">Description </th>
|
||
|
<th align="left" valign="bottom" width="57.96296296296296%" id="d0e682">Explanation </th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody><tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>07</strong>006 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Conversion not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The conversion from the data value identified
|
||
|
by the <span class="synph"><span class="var">ValueType</span></span> argument to the data type identified
|
||
|
by the <span class="synph"><span class="var">ParameterType</span></span> argument is not a meaningful
|
||
|
conversion. (For example, conversion from SQL_C_DATE to SQL_DOUBLE.)</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>40</strong>003 <strong>08</strong>S01</td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Communication link failure</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The communication link between the application
|
||
|
and data source fails before the function is completed.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>58</strong>004 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Unexpected system failure</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">Unrecoverable system error.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>001 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Memory allocation failure</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">DB2 UDB CLI is unable to allocate memory
|
||
|
required to support the processing or completion of the function. </td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>003 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Program type out of range</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified by the argument <span class="synph"><span class="var">ParameterNumber</span></span> not
|
||
|
a valid data type or SQL_C_DEFAULT.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>004 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">SQL data type out of range</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified for the argument <span class="synph"><span class="var">ParameterType</span></span> is
|
||
|
not a valid SQL data type.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>009 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Argument value not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The argument <span class="synph"><span class="var">ParameterValuePtr</span></span> is
|
||
|
a null pointer and the argument <span class="synph"><span class="var">StrLen_or_IndPtr</span></span> is
|
||
|
a null pointer, and <span class="synph"><span class="var">InputOutputType</span></span> is not SQL_PARAM_OUTPUT.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>010 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Function sequence error</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">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="12.962962962962962%" headers="d0e678 "><strong>HY</strong>013 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Unexpected memory handling error</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">DB2 UDB CLI is unable to access memory required
|
||
|
to support the processing or completion of the function.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>014</td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Too many handles</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The maximum number of handles has been allocated.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>021</td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Inconsistent descriptor information</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The descriptor information checked during
|
||
|
a consistency check is not consistent.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>090 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">String or buffer length not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified for the argument <span class="synph"><span class="var">BufferLength</span></span> is
|
||
|
less than 0.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>093 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Parameter number not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified for the argument <span class="synph"><span class="var">ValueType</span></span> is
|
||
|
less than 1 or greater than the maximum number of parameters supported by
|
||
|
the server.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>094</td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Scale value not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified for <span class="synph"><span class="var">ParameterType</span></span> is
|
||
|
either SQL_DECIMAL or SQL_NUMERIC and the value specified for <span class="synph"><span class="var">DecimalDigits</span></span> is
|
||
|
less than 0 or greater than the value for the argument <span class="synph"><span class="var">ParamDef</span></span> (precision).
|
||
|
<p>The value specified for <span class="synph"><span class="var">ParameterType</span></span> is SQL_C_TIMESTAMP
|
||
|
and the value for <span class="synph"><span class="var">ParameterType</span></span> is either SQL_CHAR
|
||
|
or SQL_VARCHAR and the value for <span class="synph"><span class="var">DecimalDigits</span></span> is
|
||
|
less than 0 or greater than 6.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>104</td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Precision value not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">The value specified for <span class="synph"><span class="var">ParameterType</span></span> is
|
||
|
either SQL_DECIMAL or SQL_NUMERIC and the value specified for <span class="synph"><span class="var">ParamDef</span></span> is
|
||
|
less than 1.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>105 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Parameter type not valid</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 "><span class="synph"><span class="var">InputOutputType</span></span> is
|
||
|
not one of SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, or SQL_PARAM_INPUT_OUTPUT.</td>
|
||
|
</tr>
|
||
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e678 "><strong>HY</strong>C00 </td>
|
||
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e680 ">Driver not capable</td>
|
||
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e682 ">DB2 UDB CLI or data source does not support
|
||
|
the conversion specified by the combination of the value specified for the
|
||
|
argument <span class="synph"><span class="var">ValueType</span></span> and the value specified for the
|
||
|
argument <span class="synph"><span class="var">ParameterType</span></span>. <p>The value specified
|
||
|
for the argument <span class="synph"><span class="var">ParameterType</span></span> is not supported
|
||
|
by either DB2 UDB
|
||
|
CLI or the data source.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">References</h4><div class="p"> <ul><li><a href="rzadpfnexecd.htm#rzadpfnexecd">SQLExecDirect - Execute a statement directly</a></li>
|
||
|
<li><a href="rzadpfnexec.htm#rzadpfnexec">SQLExecute - Execute a statement</a></li>
|
||
|
<li><a href="rzadpfnparad.htm#rzadpfnparad">SQLParamData - Get next parameter for which a data value is needed</a></li>
|
||
|
<li><a href="rzadpfnpdata.htm#rzadpfnpdata">SQLPutData - Pass data value for a parameter</a></li>
|
||
|
</ul>
|
||
|
</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>
|