doc-exports/docs/dws/dev/dws_04_0130.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

103 lines
11 KiB
HTML

<a name="EN-US_TOPIC_0000001188482142"></a><a name="EN-US_TOPIC_0000001188482142"></a>
<h1 class="topictitle1">SQLBindParameter</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188482142__s299d89cba63f4d26a8d73930ee0af19e"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188482142__a82c90a433e1a4cacbec734ef0e367ad1"><strong id="EN-US_TOPIC_0000001188482142__b842352706102448">SQLBindParameter</strong> is used to associate (bind) parameter markers in an SQL statement to a buffer.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482142__s096600c0f5414a6c9ebfa6ee68d4a0e1"><h4 class="sectiontitle">Prototype</h4><div class="codecoloring" codetype="Cpp" id="EN-US_TOPIC_0000001188482142__sfeafc76d46c040f8a0dbe2950f2e7105"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SQLRETURN</span><span class="w"> </span><span class="nf">SQLBindParameter</span><span class="p">(</span><span class="n">SQLHSTMT</span><span class="w"> </span><span class="n">StatementHandle</span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">SQLUSMALLINT</span><span class="w"> </span><span class="n">ParameterNumber</span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">SQLSMALLINT</span><span class="w"> </span><span class="n">InputOutputType</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLSMALLINT</span><span class="w"> </span><span class="n">ValuetType</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLSMALLINT</span><span class="w"> </span><span class="n">ParameterType</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLULEN</span><span class="w"> </span><span class="n">ColumnSize</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLSMALLINT</span><span class="w"> </span><span class="n">DecimalDigits</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLPOINTER</span><span class="w"> </span><span class="n">ParameterValuePtr</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLLEN</span><span class="w"> </span><span class="n">BufferLength</span><span class="p">,</span>
<span class="w"> </span><span class="n">SQLLEN</span><span class="w"> </span><span class="o">*</span><span class="n">StrLen_or_IndPtr</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482142__s31ca4b6d68124eb487106ae429adb05b"><h4 class="sectiontitle">Parameter</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482142__tbea9b3872c854b9785a51365ae844c4c" frame="border" border="1" rules="all"><caption><b>Table 1 </b>SQLBindParameter</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482142__re94e3ffacda64bbcae0774270f5ab597"><th align="left" class="cellrowborder" valign="top" width="24.5%" id="mcps1.3.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188482142__aaa10d0cc13fc4eb8ab2c79e8af8c3bee">Keyword</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="75.5%" id="mcps1.3.3.2.2.3.1.2"><p id="EN-US_TOPIC_0000001188482142__a5f34aaf5ca214c33b820d47fe1bb8e6d">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188482142__rc67b156c917d4475bc6a11f048107a71"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__a48523cc4e9be46cab193890d448b87fd">StatementHandle</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a60dbee6f809f440aabd3840b3cb3ac1c">Statement handle.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r7044a39a351740138f44463355d06c5f"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__acbafd18ef9bc4c0686227fc7ce0c1670">ParameterNumber</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__ac9dbeabdf03845d28d3046aec47a457f">Parameter marker number, starting at 1 and increasing in an ascending order.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r135cafb3fca941e39d306f7f183ebae1"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__acaebc4a9d7dc4c3493cc748ce73da5a6">InputOutputType</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a19d47f9dce1a42ecbffc540b63040c24">Input/output type of the parameter.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r856889b359a14492bc57dfbeca8dec33"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__a9129b0e91d4b448d863befa9f19a9334">ValueType</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a5d82f53cc6c34c04bd156f620d4a03c0">C data type of the parameter.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r5fbf3cc7e3734fbea82165b0a167aec6"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__a567ce11cc21846e7b60ada7dcb539c6b">ParameterType</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__ad59a03e0476340e7bbdf6f2f298922b4">SQL data type of the parameter.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r2cbeed8b4eba4becb0e60ae7e3b4dadc"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__ac5a7f32ef7694b4b8860a6f879b63643">ColumnSize</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__abd9b0a4d10d941a0add18501acf55818">Size of the column or expression of the corresponding parameter marker.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r2ddaa40e5c87405d8a9e24635c4f57c3"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__a7c41b074a816478aad01ff36e39aa92b">DecimalDigits</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__adc39e56c0f754839b8112a3b114e051a">Digital number of the column or the expression of the corresponding parameter marker.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r5ee68f7ad9c449d8a2abb0e1d2a4e24e"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__ae9778b5c9a364166a01e2fe055342be2">ParameterValuePtr</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a62de358c0c3843b7942ccb6293b0a78a">Pointer to the storage parameter buffer.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r9074dca473274499823532d24cc45602"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__a85f8f268bcd64b3a9473628243e0c4d4">BufferLength</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a4c6c51ac14b8459db76f7ed62e9612da">Size of the ParameterValuePtr buffer in bytes.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482142__r9061872f86564af1ac0c74bb977cfb3e"><td class="cellrowborder" valign="top" width="24.5%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482142__acb550f272b00423ab44fc3ce3293d2a8">StrLen_or_IndPtr</p>
</td>
<td class="cellrowborder" valign="top" width="75.5%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482142__a16843aeda8d54796a09c7f224af9db5e">Pointer to the length or indicator of the buffer. If StrLen_or_IndPtr is null, no length or indicator is used.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482142__s4c8a7003dd604561818b6a008be7bbe3"><h4 class="sectiontitle">Return Values</h4><ul id="EN-US_TOPIC_0000001188482142__ua3ac63c2dd544ede80535fa047e9ed44"><li id="EN-US_TOPIC_0000001188482142__en-us_topic_0059778788_li44335342173"><strong id="EN-US_TOPIC_0000001188482142__b842352706112950">SQL_SUCCESS</strong> indicates that the call succeeded.</li><li id="EN-US_TOPIC_0000001188482142__led7e34c863e049a5ab973bd88d590030"><strong id="EN-US_TOPIC_0000001188482142__b842352706112952">SQL_SUCCESS_WITH_INFO</strong> indicates some warning information is displayed.</li><li id="EN-US_TOPIC_0000001188482142__l3e791ddb54f24e54aaef31849af28d37"><strong id="EN-US_TOPIC_0000001188482142__b842352706112954">SQL_ERROR</strong> indicates major errors, such as memory allocation and connection failures.</li><li id="EN-US_TOPIC_0000001188482142__leb78c9d3b3b64b26a4f3eaf71e621748"><strong id="EN-US_TOPIC_0000001188482142__b842352706112956">SQL_INVALID_HANDLE</strong> indicates that invalid handles were called. Values returned by other APIs are similar to the preceding values.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482142__s261cc10af0ab48408aeed23331b20915"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188482142__ab5fb6b08110545cab529fd3e2ff75634">If <strong id="EN-US_TOPIC_0000001188482142__b842352706173815">SQLBindCol</strong> returns <strong id="EN-US_TOPIC_0000001188482142__b842352706173817">SQL_ERROR</strong> or <strong id="EN-US_TOPIC_0000001188482142__b842352706173818">SQL_SUCCESS_WITH_INFO</strong>, the application can then call <a href="dws_04_0143.html">SQLGetDiagRec</a>, with <strong id="EN-US_TOPIC_0000001188482142__b842352706173833">HandleType</strong> and <strong id="EN-US_TOPIC_0000001188482142__b842352706173850">Handle</strong> set to <strong id="EN-US_TOPIC_0000001188482142__b842352706173852">SQL_HANDLE_STMT</strong> and <strong id="EN-US_TOPIC_0000001188482142__b842352706173855">StatementHandle</strong>, respectively, to obtain the <strong id="EN-US_TOPIC_0000001188482142__b842352706173858">SQLSTATE</strong> value. The <strong id="EN-US_TOPIC_0000001188482142__b84235270617390">SQLSTATE</strong> value provides the detailed function calling information.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482142__s370b28f914d7439d981eed9259649443"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188482142__ad8572c305ddf4338aa6d6f503900664f">See <a href="dws_04_0123.html">Examples</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0124.html">ODBC Interfaces</a></div>
</div>
</div>