doc-exports/docs/dws/dev/dws_04_0129.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

75 lines
9.0 KiB
HTML

<a name="EN-US_TOPIC_0000001188163770"></a><a name="EN-US_TOPIC_0000001188163770"></a>
<h1 class="topictitle1">SQLBindCol</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188163770__s33e52ff780664d678e9dffcc3e2fe252"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188163770__a3825c56431864148835e945434b52ca3"><strong id="EN-US_TOPIC_0000001188163770__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_0000001188163770__s05d82877fae24c32851caab9da9bc2ad"><h4 class="sectiontitle">Prototype</h4><div class="codecoloring" codetype="Cpp" id="EN-US_TOPIC_0000001188163770__scced094bd8844ca89c6bb56115b29f0e"><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="n">SQLPOINTER</span><span class="w"> </span><span class="n">TargetValuePtr</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_0000001188163770__sa9eedc133e1b4c5ebf1ab0d877eeb8cf"><h4 class="sectiontitle">Parameter</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188163770__t74ba715562be4ad688da27a8580011e8" frame="border" border="1" rules="all"><caption><b>Table 1 </b>SQLBindCol parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188163770__rbcc19508f2c940a0bee483ad7b2fefca"><th align="left" class="cellrowborder" valign="top" width="23.27%" id="mcps1.3.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188163770__a4c8c5f4926bb4d379596a8ab558d47ca">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_0000001188163770__a5ce21a3923614ae3a25c4e8c99e7a986">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188163770__r3037603acd194bf6aec2a8380f61b368"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__af69021543f4743e5ac70b92f782f5d46">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_0000001188163770__a74a06dedfffe4739a74604881a5e2d76">Statement handle.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163770__r7b5a143f27b04fe791f33944cf129f00"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__afc6c45e255344626a75fbc7464b1c6d9">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_0000001188163770__a96794412a876453591bbefae760f7599">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_0000001188163770__rc48d4ebf7e3345b88480505b07e17efb"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__aebfbe4e7af2848979a6381723957066b">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_0000001188163770__a4ba3156029734fddae1941bd4b1971a7">The C data type in the buffer.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163770__r0aad64522e1f4a908675fd7b04cea85e"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__a6270e066f48d4fcb8eee1fc7ce216a99">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_0000001188163770__ad8981bafaf644db985631f8151a4458d"><strong id="EN-US_TOPIC_0000001188163770__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_0000001188163770__b84235270617330">TargetValuePtr</strong> is null, <strong id="EN-US_TOPIC_0000001188163770__b84235270617333">StrLen_or_IndPtr</strong> is a valid value.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163770__r6d64eb8beece430abadf7d52bd739292"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__ac2cd8c4e2e064745be4228ad93cfd647">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_0000001188163770__a54d9da91d79d4cd3af614b5e6e6e3d9c">Size of the <strong id="EN-US_TOPIC_0000001188163770__b842352706173311">TargetValuePtr</strong> buffer in bytes available to store the column data.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163770__r698245daaffb4d0e828719d74e4880b9"><td class="cellrowborder" valign="top" width="23.27%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163770__a1d6bedea7e8d4f18bbad60e740b67fac">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_0000001188163770__a3c1793e03cf74f4f992433d2d9efc2b4"><strong id="EN-US_TOPIC_0000001188163770__b842352706173325">Output parameter</strong>: pointer to the length or indicator of the buffer. If <strong id="EN-US_TOPIC_0000001188163770__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_0000001188163770__s9d61ca31ea014f9998d406045753b1c4"><h4 class="sectiontitle">Return Values</h4><ul id="EN-US_TOPIC_0000001188163770__u880e8cb338d448d09679b978e3f84414"><li id="EN-US_TOPIC_0000001188163770__en-us_topic_0059779335_li99448223177">SQL_SUCCESS indicates that the call succeeded.</li><li id="EN-US_TOPIC_0000001188163770__l88a3443d2e1e44fe9548161f9bd25439">SQL_SUCCESS_WITH_INFO indicates some warning information is displayed.</li><li id="EN-US_TOPIC_0000001188163770__l69ae8daeb8034c5bb82ed75011ea1c14">SQL_ERROR indicates major errors, such as memory allocation and connection failures.</li><li id="EN-US_TOPIC_0000001188163770__l04bd47d7e76344d7b67f63654e65c8b1">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_0000001188163770__sad9f36d2cb13462b9e9625fdf6a6fc07"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188163770__afcdd3e26e54d4d4aab67a91bb3ea4afb">If <strong id="EN-US_TOPIC_0000001188163770__b842352706173815">SQLBindCol</strong> returns <strong id="EN-US_TOPIC_0000001188163770__b842352706173817">SQL_ERROR</strong> or <strong id="EN-US_TOPIC_0000001188163770__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_0000001188163770__b842352706173833">HandleType</strong> and <strong id="EN-US_TOPIC_0000001188163770__b842352706173850">Handle</strong> set to <strong id="EN-US_TOPIC_0000001188163770__b842352706173852">SQL_HANDLE_STMT</strong> and <strong id="EN-US_TOPIC_0000001188163770__b842352706173855">StatementHandle</strong>, respectively, to obtain the <strong id="EN-US_TOPIC_0000001188163770__b842352706173858">SQLSTATE</strong> value. The <strong id="EN-US_TOPIC_0000001188163770__b84235270617390">SQLSTATE</strong> value provides the detailed function calling information.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188163770__s5f2e5d60a4c6409386cabfd839440211"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188163770__aa41e08e7ee4c4b0fa60d7e25fdaa6089">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>