doc-exports/docs/dws/dev/dws_04_0129.html
Lu, Huayi a24ca60074 DWS DEVELOPER 811 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-01-19 13:37:49 +00:00

75 lines
9.1 KiB
HTML

<a name="EN-US_TOPIC_0000001145814823"></a><a name="EN-US_TOPIC_0000001145814823"></a>
<h1 class="topictitle1">SQLBindCol</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001145814823__s02128a95eb16411dbe905625973c4ac4"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001145814823__a80d7406ad18746fb9e1ccc5b1aa050b6"><strong id="EN-US_TOPIC_0000001145814823__b842352706172959">SQLBindCol</strong> is used to associate (bind) columns in a result set to an application data buffer.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001145814823__sfa8a49be36de494da938010d89341509"><h4 class="sectiontitle">Prototype</h4><div class="codecoloring" codetype="Cpp" id="EN-US_TOPIC_0000001145814823__s0c768e846b9c4346a94f7bf345279732"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">SQLRETURN</span><span class="w"> </span><span class="nf">SQLBindCol</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">ColumnNumber</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">TargetType</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="n">SQLPOINTER</span><span class="w"> </span><span class="n">TargetValuePtr</span><span class="p">,</span><span class="w"></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="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><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001145814823__sba2cdc9b40da45c2bdc371b20acddc3f"><h4 class="sectiontitle">Parameter</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001145814823__t1eb8292ec9014487924c174878ebceff" frame="border" border="1" rules="all"><caption><b>Table 1 </b>SQLBindCol parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001145814823__r39008f5c1fa54c88b7b13c270e983e92"><th align="left" class="cellrowborder" valign="top" width="23.27%" id="mcps1.3.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001145814823__aaaa1ef6dd4194af6ac342aefa139a117">Keyword</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="76.73%" id="mcps1.3.3.2.2.3.1.2"><p id="EN-US_TOPIC_0000001145814823__a459a6d40afb64d6b8bab9072c84327bf">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001145814823__r8a4dcc56d6504f4bb299530589a267b1"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__a0cef2e0b89604404a2ac1899afec29de">StatementHandle</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__aafffe2d6b84a4f4686c336fd361b3fcb">Statement handle.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145814823__r16d17b4252e448d49a27ea6ee629afc2"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__ad84d22342a0e460ab3dad9a6f9aab351">ColumnNumber</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__aaa1c2df0db764dfcbf75f9d35beef7c7">Number of the column to be bound. The column number starts with 0 and increases in ascending order. Column 0 is the bookmark column. If no bookmark column is set, column numbers start at 1.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145814823__rd829a30d35b44e6896b2f180cb625322"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__a70e169cb418e4428b582d7178cf0b3c0">TargetType</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__a3d4f2587f7fb43878ef8155ba3beba97">The C data type in the buffer.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145814823__r57b968fe6e69405ea6bfbbb9efa55741"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__ad239ecf121d64b81a99e7d673bd50327">TargetValuePtr</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__a9b912db16e7243dc8787f8d70bd2f5dc"><strong id="EN-US_TOPIC_0000001145814823__b842352706173247">Output parameter</strong>: pointer to the buffer bound with the column. The SQLFetch function returns data in the buffer. If <strong id="EN-US_TOPIC_0000001145814823__b84235270617330">TargetValuePtr</strong> is null, <strong id="EN-US_TOPIC_0000001145814823__b84235270617333">StrLen_or_IndPtr</strong> is a valid value.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145814823__r727447b7eb884d1d80c020362e036f3a"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__af124a6fd3d14425a8f27a40cdcc3809d">BufferLength</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__a9c7fe5292e7640ccb14da3cea0263816">Size of the <strong id="EN-US_TOPIC_0000001145814823__b842352706173311">TargetValuePtr</strong> buffer in bytes available to store the column data.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145814823__re05119e303c140228b8b766bee537ae6"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001145814823__a3f96a73aaedb448ba728b85778b734e0">StrLen_or_IndPtr</p>
</td>
<td class="cellrowborder" valign="top" width="76.73%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001145814823__aa9a69abb7f3c45a389fd39b7d55928f1"><strong id="EN-US_TOPIC_0000001145814823__b842352706173325">Output parameter</strong>: pointer to the length or indicator of the buffer. If <strong id="EN-US_TOPIC_0000001145814823__b842352706173345">StrLen_or_IndPtr</strong> is null, no length or indicator is used.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001145814823__s423c506003904bbea41400221c0222ae"><h4 class="sectiontitle">Return Values</h4><ul id="EN-US_TOPIC_0000001145814823__u5a05e00ea3fc4bd39e887b576177b18c"><li id="EN-US_TOPIC_0000001145814823__en-us_topic_0059779335_li99448223177">SQL_SUCCESS indicates that the call succeeded.</li><li id="EN-US_TOPIC_0000001145814823__le867f3654c4640bb9a2defd95047ab50">SQL_SUCCESS_WITH_INFO indicates some warning information is displayed.</li><li id="EN-US_TOPIC_0000001145814823__l5ead10596ca94b1fa55a208ba6f20c33">SQL_ERROR indicates major errors, such as memory allocation and connection failures.</li><li id="EN-US_TOPIC_0000001145814823__la27666e5be964b409584377ddda5c592">SQL_INVALID_HANDLE 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_0000001145814823__sc86a160c283748b7983ccb6d7ea65179"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001145814823__a7f46580c74c84325bba97410e955a482">If <strong id="EN-US_TOPIC_0000001145814823__b842352706173815">SQLBindCol</strong> returns <strong id="EN-US_TOPIC_0000001145814823__b842352706173817">SQL_ERROR</strong> or <strong id="EN-US_TOPIC_0000001145814823__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_0000001145814823__b842352706173833">HandleType</strong> and <strong id="EN-US_TOPIC_0000001145814823__b842352706173850">Handle</strong> set to <strong id="EN-US_TOPIC_0000001145814823__b842352706173852">SQL_HANDLE_STMT</strong> and <strong id="EN-US_TOPIC_0000001145814823__b842352706173855">StatementHandle</strong>, respectively, to obtain the <strong id="EN-US_TOPIC_0000001145814823__b842352706173858">SQLSTATE</strong> value. The <strong id="EN-US_TOPIC_0000001145814823__b84235270617390">SQLSTATE</strong> value provides the detailed function calling information.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001145814823__s3d87ce634f9c4ddf9d055c500129367e"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001145814823__ad3febb8a574a4ee2b7b7daaed95d50da">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>