forked from docs/doc-exports
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>
75 lines
10 KiB
HTML
75 lines
10 KiB
HTML
<a name="EN-US_TOPIC_0000001188163714"></a><a name="EN-US_TOPIC_0000001188163714"></a>
|
|
|
|
<h1 class="topictitle1">SQLGetData</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188163714__s8110024e2677472c991854222236e2a7"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188163714__ad06b67018b2d4f2db9c79e6ef1e38111"><strong id="EN-US_TOPIC_0000001188163714__b842352706151251">SQLGetData</strong> retrieves data for a single column in the current row of the result set. It can be called for many times to retrieve data of variable lengths.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188163714__sa3cea2d504444e36906e1a46ea9e5c4c"><h4 class="sectiontitle">Prototype</h4><div class="codecoloring" codetype="Cpp" id="EN-US_TOPIC_0000001188163714__sfc2e9555477946588a3f0bfc3291072a"><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">SQLGetData</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="n">SQLUSMALLINT</span><span class="w"> </span><span class="n">Col_or_Param_Num</span><span class="p">,</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_0000001188163714__s6f82c05a44334aeb9db2a7ae0e0d75cc"><h4 class="sectiontitle">Parameter</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188163714__td2f062e604fd487c8a31f44ced2f3dd9" frame="border" border="1" rules="all"><caption><b>Table 1 </b>SQLGetData parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188163714__r4bec3dc43a9b4a0089df224c379ef3df"><th align="left" class="cellrowborder" valign="top" width="26.040000000000003%" id="mcps1.3.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188163714__a3f486588b4e14c72b27b440e71f4b3e2">Keyword</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="73.96000000000001%" id="mcps1.3.3.2.2.3.1.2"><p id="EN-US_TOPIC_0000001188163714__ae3737572245a4e859f3e989bbfbaa0aa">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188163714__rf322182f382a4cc78f845f8d46a226d4"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__a3c866f7f7dac4e3b96d1fd4554d33214">StatementHandle</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__a6a2a87a213704e5a820d35204dd4cff0">Statement handle, obtained from <strong id="EN-US_TOPIC_0000001188163714__b842352706151326">SQLAllocHandle</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188163714__r73468b53cffb4e99bb1ade05ef9fa527"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__a2b87b5b13d384eb1a9b6a3ee0a742570">Col_or_Param_Num</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__a286bf5856ce14d618880fdde6e13d5fe">Column number for which the data retrieval is requested. The column number starts with 1 and increases in ascending order. The number of the bookmark column is 0.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188163714__ra177470816a4463ba30854d868322bda"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__aa50085f0fa8f4fce898a84f82d6f44e0">TargetType</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__a5a05418329844c158f1b4cf81b9e19ea">C data type in the TargetValuePtr buffer. If <strong id="EN-US_TOPIC_0000001188163714__b842352706151354">TargetType</strong> is <strong id="EN-US_TOPIC_0000001188163714__b842352706151357">SQL_ARD_TYPE</strong>, the driver uses the data type of the <strong id="EN-US_TOPIC_0000001188163714__b84235270615142">SQL_DESC_CONCISE_TYPE</strong> field in ARD. If <strong id="EN-US_TOPIC_0000001188163714__b842352706151410">TargetType</strong> is <strong id="EN-US_TOPIC_0000001188163714__b842352706151413">SQL_C_DEFAULT</strong>, the driver selects a default data type according to the source SQL data type.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188163714__rb97e4758481c494d85a9631bcdf56b13"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__a6e6297ab841a40cabe210b3e633cdabc">TargetValuePtr</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__a988b2fc4c78447038167f90b54953469"><strong id="EN-US_TOPIC_0000001188163714__b842352706151430">Output parameter</strong>: pointer to the pointer that points to the buffer where the data is located.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188163714__rd9047e0459a24b27a9c67e419fe05f18"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__a5d31bb604fba4dcfb1922405f8e450b2">BufferLength</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__ac1db53b2834c4dd9895c5203ae45aa93">Size of the buffer pointed to by <strong id="EN-US_TOPIC_0000001188163714__b842352706151459">TargetValuePtr</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001188163714__r6dd1a1efaeaf4c2ea6c6c458b06a8a1a"><td class="cellrowborder" valign="top" width="26.040000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188163714__a1d50a7ffbad6438ead4f4805cb51bd53">StrLen_or_IndPtr</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="73.96000000000001%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188163714__a90ed2462b4f34ee09114c1f363dfd2a3"><strong id="EN-US_TOPIC_0000001188163714__a0d31142125114e59a52a35f66747a4e6">Output parameter</strong>: pointer to the buffer where the length or identifier value is returned.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188163714__s213ee9a7b17143fc859a4978a88c7cd2"><h4 class="sectiontitle">Return Values</h4><ul id="EN-US_TOPIC_0000001188163714__u0985a15b8ac345cf944d766f254143fc"><li id="EN-US_TOPIC_0000001188163714__lfc681932366843c1b4d392c8f2efe24e"><strong id="EN-US_TOPIC_0000001188163714__b842352706112950">SQL_SUCCESS</strong> indicates that the call succeeded.</li><li id="EN-US_TOPIC_0000001188163714__l7363aead0792402cb4079310a2aaf59a"><strong id="EN-US_TOPIC_0000001188163714__b842352706112952">SQL_SUCCESS_WITH_INFO</strong> indicates some warning information is displayed.</li><li id="EN-US_TOPIC_0000001188163714__l83526b9b7ea94b46bcfd9a44000f2e4f"><strong id="EN-US_TOPIC_0000001188163714__b842352706112954">SQL_ERROR</strong> indicates major errors, such as memory allocation and connection failures.</li><li id="EN-US_TOPIC_0000001188163714__l58ac78be97344ce1a3b71068205a4a0f"><strong id="EN-US_TOPIC_0000001188163714__b84235270615213">SQL_NO_DATA</strong> indicates that the SQL statement does not return a result set.</li><li id="EN-US_TOPIC_0000001188163714__ldf4f1c436c98410ba032eeb438a0f2ea"><strong id="EN-US_TOPIC_0000001188163714__b842352706112956">SQL_INVALID_HANDLE</strong> indicates that invalid handles were called. Values returned by other APIs are similar to the preceding values.</li><li id="EN-US_TOPIC_0000001188163714__l5d71738cd294447d89efb4f13e01690b"><strong id="EN-US_TOPIC_0000001188163714__b842352706152119">SQL_STILL_EXECUTING</strong> indicates that the statement is being executed.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188163714__s1f229eb1865c4292823c4d4fb696076a"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188163714__a0ce67496501448388e0d95c495171fc2">If <strong id="EN-US_TOPIC_0000001188163714__afb1393e0482a462fb8435e3a2149798a">SQLFetch</strong> returns <strong id="EN-US_TOPIC_0000001188163714__a6c44273ac4874875b535c2067207ce2f">SQL_ERROR</strong> or <strong id="EN-US_TOPIC_0000001188163714__a0526088d224f4665a1b04ae5bd4bf33f">SQL_SUCCESS_WITH_INFO</strong>, the application can then call <a href="dws_04_0143.html">SQLGetDiagRec</a>, set <strong id="EN-US_TOPIC_0000001188163714__a3853a981224943cebfed6a0da7bab928">HandleType</strong> and <strong id="EN-US_TOPIC_0000001188163714__a6f262a53f0e948e8a2f8202fcfcaefb5">Handle</strong> to <strong id="EN-US_TOPIC_0000001188163714__a4b459f2ba70045ecbfa84d8c08a13728">SQL_HANDLE_STMT</strong> and <strong id="EN-US_TOPIC_0000001188163714__a9fe4e137ac304ae5a332be625d7fc35e">StatementHandle</strong>, and obtain the <strong id="EN-US_TOPIC_0000001188163714__abe1f29a8423b48e1af6329a971adab88">SQLSTATE</strong> value. The <strong id="EN-US_TOPIC_0000001188163714__a79a007e94cb041688943c3d529ede484">SQLSTATE</strong> value provides the detailed function calling information.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188163714__s4eae508a296d474886fdc7d7717d01ae"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188163714__ac83368e0bcc04e1b8c370f72c2570471">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>
|
|
|