doc-exports/docs/dli/api-ref/dli_02_0107.html
Su, Xiaomeng 57a0d535be dli_api_0910_version_api
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2023-10-16 22:01:57 +00:00

157 lines
13 KiB
HTML

<a name="dli_02_0107"></a><a name="dli_02_0107"></a>
<h1 class="topictitle1">Checking SQL Syntax</h1>
<div id="body1524635930709"><div class="section" id="dli_02_0107__s15d8cb8e7b7f4b47acbc825ca34ae180"><h4 class="sectiontitle">Function</h4><p id="dli_02_0107__p1653641143815">This API is used to check the SQL syntax.</p>
</div>
<div class="section" id="dli_02_0107__sec7331dc70ce415da2d94a4062c0e286"><h4 class="sectiontitle">URI</h4><ul id="dli_02_0107__en-us_topic_0069077896_ul39785843"><li id="dli_02_0107__en-us_topic_0069077896_li22528274">URI format<p id="dli_02_0107__p15298970102817"><a name="dli_02_0107__en-us_topic_0069077896_li22528274"></a><a name="en-us_topic_0069077896_li22528274"></a>POST /v1.0/{project_id}/jobs/check-sql</p>
</li><li id="dli_02_0107__li983216201242">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0107__en-us_topic_0069077896_table12850938" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameters</caption><thead align="left"><tr id="dli_02_0107__en-us_topic_0069077896_row26986831"><th align="left" class="cellrowborder" valign="top" width="17.03%" id="mcps1.3.2.2.2.1.2.5.1.1"><p id="dli_02_0107__ac4350eeb47b04ac3842d18c867bd44eb">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.23%" id="mcps1.3.2.2.2.1.2.5.1.2"><p id="dli_02_0107__a9c7aa8e702fe45d598376fcd31c9f5ce">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.88%" id="mcps1.3.2.2.2.1.2.5.1.3"><p id="dli_02_0107__p17251748292">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="57.86%" id="mcps1.3.2.2.2.1.2.5.1.4"><p id="dli_02_0107__a319b72a499674bd8befd20b6a9358879">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0107__row134331617104113"><td class="cellrowborder" valign="top" width="17.03%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="dli_02_0107__en-us_topic_0069077803_p43412436">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="13.23%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="dli_02_0107__en-us_topic_0069077803_p26746391">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.88%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="dli_02_0107__p1425144112910">String</p>
</td>
<td class="cellrowborder" valign="top" width="57.86%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="dli_02_0107__p1310472724012">Project ID, which is used for resource isolation. For details about how to obtain its value, see <a href="dli_02_0183.html">Obtaining a Project ID</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="dli_02_0107__sf71ef29ac20f4a86b617e33b97566e44"><h4 class="sectiontitle">Request</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0107__table6376584143542" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request parameters</caption><thead align="left"><tr id="dli_02_0107__row19110893143542"><th align="left" class="cellrowborder" valign="top" width="11.98989898989899%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_02_0107__p42934984143542">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.383838383838384%" id="mcps1.3.3.2.2.5.1.2"><p id="dli_02_0107__p55181642143542">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.000000000000002%" id="mcps1.3.3.2.2.5.1.3"><p id="dli_02_0107__p40528033143542">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="65.62626262626263%" id="mcps1.3.3.2.2.5.1.4"><p id="dli_02_0107__p61545269143542">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0107__row16818917143542"><td class="cellrowborder" valign="top" width="11.98989898989899%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_02_0107__p4478514143542">sql</p>
</td>
<td class="cellrowborder" valign="top" width="10.383838383838384%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_02_0107__p27215339143542">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="12.000000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_02_0107__p56958849143542">String</p>
</td>
<td class="cellrowborder" valign="top" width="65.62626262626263%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_02_0107__p1036145143542">SQL statement that you want to execute.</p>
</td>
</tr>
<tr id="dli_02_0107__row48821488143542"><td class="cellrowborder" valign="top" width="11.98989898989899%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_02_0107__p17152532143542">currentdb</p>
</td>
<td class="cellrowborder" valign="top" width="10.383838383838384%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_02_0107__p47177872143542">No</p>
</td>
<td class="cellrowborder" valign="top" width="12.000000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_02_0107__p63311321143542">String</p>
</td>
<td class="cellrowborder" valign="top" width="65.62626262626263%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_02_0107__p27943382143542">Database where the SQL statement is executed.</p>
<div class="note" id="dli_02_0107__note2355567214459"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="dli_02_0107__ul59257121144616"><li id="dli_02_0107__li32523421144616">If the SQL statement contains <strong id="dli_02_0107__b842352706155123">db_name</strong>, for example, <i><b><span class="cmdname" style="font-family:Arial" id="dli_02_0107__cmdname5519514415">select * from db1.t1</span></b></i>, you do not need to set this parameter.</li><li id="dli_02_0107__li47087460144616">If the SQL statement does not contain <strong id="dli_02_0107__b84235270615520">db_name</strong>, the semantics check will fail when you do not set this parameter or set this parameter to an incorrect value.</li></ul>
</div></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_02_0107__s3cacdc89985c49fa9b00c879e3880d15"><h4 class="sectiontitle">Response</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0107__en-us_topic_0069077896_table33203075" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Response parameters</caption><thead align="left"><tr id="dli_02_0107__en-us_topic_0069077896_row35922485"><th align="left" class="cellrowborder" valign="top" width="13.820000000000002%" id="mcps1.3.4.2.2.5.1.1"><p id="dli_02_0107__a5212f67c295f4ae7a136c5eb4d263e47">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.420000000000002%" id="mcps1.3.4.2.2.5.1.2"><p id="dli_02_0107__p6901173019816">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.930000000000003%" id="mcps1.3.4.2.2.5.1.3"><p id="dli_02_0107__en-us_topic_0069077896_p944819142913">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="60.830000000000005%" id="mcps1.3.4.2.2.5.1.4"><p id="dli_02_0107__en-us_topic_0069077896_p944851413912">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0107__en-us_topic_0069077896_row12898672"><td class="cellrowborder" valign="top" width="13.820000000000002%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0107__en-us_topic_0069077896_p38159543">is_success</p>
</td>
<td class="cellrowborder" valign="top" width="12.420000000000002%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0107__p1690110300812">No</p>
</td>
<td class="cellrowborder" valign="top" width="12.930000000000003%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0107__en-us_topic_0069077896_p48699120">Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="60.830000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0107__p1216075194811">Indicates whether the request is successfully executed. Value <span class="parmvalue" id="dli_02_0107__parmvalue2253974916747"><b>true</b></span> indicates that the request is successfully executed.</p>
</td>
</tr>
<tr id="dli_02_0107__en-us_topic_0069077896_row1070040"><td class="cellrowborder" valign="top" width="13.820000000000002%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0107__en-us_topic_0069077896_p19564417">message</p>
</td>
<td class="cellrowborder" valign="top" width="12.420000000000002%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0107__p199017301087">No</p>
</td>
<td class="cellrowborder" valign="top" width="12.930000000000003%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0107__en-us_topic_0069077896_p49998030">String</p>
</td>
<td class="cellrowborder" valign="top" width="60.830000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0107__a4fa277540d3e42e48cec2027a36ca6bc">System prompt. If execution succeeds, the parameter setting may be left blank.</p>
</td>
</tr>
<tr id="dli_02_0107__row6356115711103"><td class="cellrowborder" valign="top" width="13.820000000000002%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_02_0107__p2035713573103">job_type</p>
</td>
<td class="cellrowborder" valign="top" width="12.420000000000002%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_02_0107__p1535785721016">No</p>
</td>
<td class="cellrowborder" valign="top" width="12.930000000000003%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_02_0107__en-us_topic_0069077810_p33533331">String</p>
</td>
<td class="cellrowborder" valign="top" width="60.830000000000005%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_02_0107__a2b151253b7da4442994ace501caef7ea">Type of a job. Job types include the following: <strong id="dli_02_0107__b2019422385914">DDL</strong>, <strong id="dli_02_0107__b1519532315916">DCL</strong>, <strong id="dli_02_0107__b17195172355913">IMPORT</strong>, <strong id="dli_02_0107__b121961923175911">EXPORT</strong>, <strong id="dli_02_0107__b16196112335914">QUERY</strong>, and <strong id="dli_02_0107__b919762313592">INSERT</strong>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_02_0107__section1267554313159"><h4 class="sectiontitle">Example Request</h4><p id="dli_02_0107__p29561854192314">Check the syntax of the SQL statement <strong id="dli_02_0107__b146861827171220">select * from t1</strong>.</p>
<pre class="screen" id="dli_02_0107__screen29436408151124">{
"currentdb": "db1",
"sql": "select * from t1"
}</pre>
</div>
<div class="section" id="dli_02_0107__section43379838151112"><h4 class="sectiontitle">Example Response</h4><pre class="screen" id="dli_02_0107__screen1998237151132">{
"is_success": true,
"message": "the sql is ok",
"job_type":"QUERY"
}</pre>
</div>
<div class="section" id="dli_02_0107__sf39cfd445ad24e9e82754fcb0027179d"><h4 class="sectiontitle">Status Codes</h4><p id="dli_02_0107__a04144ca3a08e4576b386c6a98f43a2ae"><a href="#dli_02_0107__tb12870f1c5f24b27abd55ca24264af36">Table 4</a> describes the status code.</p>
<div class="tablenoborder"><a name="dli_02_0107__tb12870f1c5f24b27abd55ca24264af36"></a><a name="tb12870f1c5f24b27abd55ca24264af36"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_02_0107__tb12870f1c5f24b27abd55ca24264af36" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Status codes</caption><thead align="left"><tr id="dli_02_0107__r8d54231f95b14c01a5e55e95f3b2e838"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.7.3.2.3.1.1"><p id="dli_02_0107__ab49d21f312644072a331f43e92baf853">Status Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.7.3.2.3.1.2"><p id="dli_02_0107__aea1d3bd107bb4c499da79a88832d256c">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_02_0107__r211ad4eb571d4d938e5579998723174e"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0107__a3153e07b3a9749adba92599fe6628fbf">200</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0107__p104431642124811">The request is successful.</p>
</td>
</tr>
<tr id="dli_02_0107__row44937531727"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0107__p184941532219">400</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0107__p2049413539219">Request error.</p>
</td>
</tr>
<tr id="dli_02_0107__row65331212142411"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.7.3.2.3.1.1 "><p id="dli_02_0107__p5537171216249">500</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.7.3.2.3.1.2 "><p id="dli_02_0107__p953813124249">Internal service error.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_02_0107__section13596141025715"><h4 class="sectiontitle">Error Codes</h4><p id="dli_02_0107__p420584425712">If an error occurs when this API is invoked, the system does not return the result similar to the preceding example, but returns the error code and error information. For details, see <a href="dli_02_0056.html">Error Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_02_0158.html">SQL Job related APIs</a></div>
</div>
</div>