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

54 lines
7.5 KiB
HTML

<a name="EN-US_TOPIC_0000001188323628"></a><a name="EN-US_TOPIC_0000001188323628"></a>
<h1 class="topictitle1">SQLExecDirect</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188323628__saf7ab07481404156b6c93aa87f03aa23"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188323628__a9912a78f03754b769659e8757f2e51c5"><strong id="EN-US_TOPIC_0000001188323628__b842352706142823">SQLExecDirect</strong> executes a prepared SQL statement specified in this parameter. This is the fastest execution method for executing only one SQL statement at a time.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188323628__s7df68372f0694e82964a20e65a08fbd3"><h4 class="sectiontitle">Prototype</h4><div class="codecoloring" codetype="Cpp" id="EN-US_TOPIC_0000001188323628__sdd08c87f53a244ae8276b14c17f9c917"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">SQLRETURN</span><span class="w"> </span><span class="nf">SQLExecDirect</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">SQLCHAR</span><span class="w"> </span><span class="o">*</span><span class="n">StatementText</span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">SQLINTEGER</span><span class="w"> </span><span class="n">TextLength</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188323628__s1486b55290b447c59b8b6d5c5620aae1"><h4 class="sectiontitle">Parameter</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188323628__t657b6cdb48c24a868b0c0886145aa8ce" frame="border" border="1" rules="all"><caption><b>Table 1 </b>SQLExecDirect parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188323628__rac18cb24e85d49dc831a8f9771534ece"><th align="left" class="cellrowborder" valign="top" width="23.580000000000002%" id="mcps1.3.3.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188323628__a67c13fc27ab544aa98587074703128e7">Keyword</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="76.42%" id="mcps1.3.3.2.2.3.1.2"><p id="EN-US_TOPIC_0000001188323628__a41eac8a407454776a7c8256e8a0702d9">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188323628__rb51100b139b14a8e941bb4028e93555e"><td class="cellrowborder" valign="top" width="23.580000000000002%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188323628__a9c32164a5973436aafe66d0b96e69b6a">StatementHandle</p>
</td>
<td class="cellrowborder" valign="top" width="76.42%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188323628__abd99a39751644bd99aa25aba06d2cde0">Statement handle, obtained from <strong id="EN-US_TOPIC_0000001188323628__b842352706142916">SQLAllocHandle</strong>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188323628__rc43edadd4cb943bfb28a69b33a0bd697"><td class="cellrowborder" valign="top" width="23.580000000000002%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188323628__a50f3573def1649d28a53995268b66ec1">StatementText</p>
</td>
<td class="cellrowborder" valign="top" width="76.42%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188323628__ad20fcea54a824675b7afcfa4a5c38ecf">SQL statement to be executed. One SQL statement can be executed at a time.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188323628__r32dcf93758b04ee0b55f65bf288e21c9"><td class="cellrowborder" valign="top" width="23.580000000000002%" headers="mcps1.3.3.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188323628__aec8911aa774e4b22a5432e53d978bcdc">TextLength</p>
</td>
<td class="cellrowborder" valign="top" width="76.42%" headers="mcps1.3.3.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188323628__ac5774b8e1ccb469496efdae724b18f0d">Length of <strong id="EN-US_TOPIC_0000001188323628__b43579298162725">StatementText</strong>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188323628__s04c6e7e6a6d846c7b331f475ca4148a4"><h4 class="sectiontitle">Return Values</h4><ul id="EN-US_TOPIC_0000001188323628__u8971698e18134c7ba3b91f489d55b645"><li id="EN-US_TOPIC_0000001188323628__l5f034a12ea07449593b69f6b216c98fa"><strong id="EN-US_TOPIC_0000001188323628__b842352706112950">SQL_SUCCESS</strong> indicates that the call succeeded.</li><li id="EN-US_TOPIC_0000001188323628__la351f527f2a74a96aca46e3b088e33c8"><strong id="EN-US_TOPIC_0000001188323628__b842352706112952">SQL_SUCCESS_WITH_INFO</strong> indicates some warning information is displayed.</li><li id="EN-US_TOPIC_0000001188323628__l1afd7bfd15d4451daed2c33cb97cbc28"><strong id="EN-US_TOPIC_0000001188323628__b842352706151539">SQL_NEED_DATA</strong> indicates insufficient parameters provided before executing the SQL statement.</li><li id="EN-US_TOPIC_0000001188323628__l154886a10ef546edaa1fa5bb630444c8"><strong id="EN-US_TOPIC_0000001188323628__b842352706112954">SQL_ERROR</strong> indicates major errors, such as memory allocation and connection failures.</li><li id="EN-US_TOPIC_0000001188323628__l8627a3284af940409fa3543ec3ab4802"><strong id="EN-US_TOPIC_0000001188323628__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_0000001188323628__l23667c98e5e04245a11d7d26b5d59449"><strong id="EN-US_TOPIC_0000001188323628__b842352706152119">SQL_STILL_EXECUTING</strong> indicates that the statement is being executed.</li><li id="EN-US_TOPIC_0000001188323628__l103a865739644676993437a4d2f13501"><strong id="EN-US_TOPIC_0000001188323628__b84235270615213">SQL_NO_DATA</strong> indicates that the SQL statement does not return a result set.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188323628__s1340545ab32241ca8610af1354dfa8ad"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188323628__a9ce73bee56e041b5b63168b2e0d334b7">If <strong id="EN-US_TOPIC_0000001188323628__b27970617162014">SQLExecDirect</strong> returns <strong id="EN-US_TOPIC_0000001188323628__b14889512162019">SQL_ERROR</strong> or <strong id="EN-US_TOPIC_0000001188323628__b36828524162026">SQL_SUCCESS_WITH_INFO</strong>, the application can then call <a href="dws_04_0143.html">SQLGetDiagRec</a>, set <strong id="EN-US_TOPIC_0000001188323628__b32755184162030">HandleType</strong> and <strong id="EN-US_TOPIC_0000001188323628__b24477965162036">Handle</strong> to <strong id="EN-US_TOPIC_0000001188323628__b897061162041">SQL_HANDLE_STMT</strong> and <strong id="EN-US_TOPIC_0000001188323628__b32545914162047">StatementHandle</strong>, and obtain the <strong id="EN-US_TOPIC_0000001188323628__b6486132162053">SQLSTATE</strong> value. The <strong id="EN-US_TOPIC_0000001188323628__b34506135162058">SQLSTATE</strong> value provides the detailed function calling information.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188323628__s4b59ff03a1a749d5886d544898c1f8e5"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188323628__adb8b978ad0a74549b48e4ec3fe55dd6a">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>