Executes SQL statements.
You can call this operation only for instances that are managed in Security Collaboration mode.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | ExecuteScript |
The operation that you want to perform. Set the value to ExecuteScript. |
DbId | Integer | Yes | 123 |
The ID of the database. Note This parameter is equivalent to the DatabaseId parameter in the SearchDatabase, ListDatabases, and GetDatabase operations. You can call one of these operations to obtain the required database ID. For more information, see SearchDatabase, ListDatabases, and GetDatabase.
|
Logic | Boolean | Yes | false |
Specifies whether the database is a logical database. |
Script | String | Yes | select dt from report_daily |
The SQL statements to be executed. Data query language (DQL) statements, data definition language (DDL) statements, and data manipulation language (DML) statements are supported. The control mode of the instance that you want to query determines whether you can execute DDL and DML statements. |
Tid | Long | No | 234 |
The ID of the tenant. Note To obtain the tenant ID, move the pointer over the profile picture in the upper-right
corner of the Data Management (DMS) console. For more information, see Tenant information.
|
RegionId | String | No | cn-hangzhou |
The region where you want to call this operation. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
ErrorCode | String | UnknownError |
The error code. |
ErrorMessage | String | UnknownError |
The error message about the gateway. |
RequestId | String | FE8EE2F1-4880-46BC-A704-5CF63EAF9A04 |
The ID of the request. |
Results | Array of Result |
The results of the SQL statements that are executed, in the format of an array. Each entry in the array indicates the result of an SQL statement. |
|
ColumnNames | List | ["col1", "col2"] |
The fields that are queried after the SQL statement is executed. |
Message | String | UnknownError |
The error message that is returned if the SQL statement fails to be executed. For example, an error message is returned because the SQL statement is invalid. |
RowCount | Long | 1 |
The total number of entries that are returned. |
Rows | List | [{"col1": "value1", "col2":"value2"}] |
The rows that are queried after the SQL statement is executed. |
Success | Boolean | true |
Indicates whether the SQL statement is executed. |
Success | Boolean | true |
Indicates whether the request is successful. |
Examples
Sample requests
http(s)://[Endpoint]/? Action=ExecuteScript
&DbId=123
&Logic=false
&Script=select dt from report_daily
&<Common request parameters>
Sample success responses
XML
format
<RequestId>FE8EE2F1-4880-46BC-A704-5CF63EAF9A04</RequestId>
<Results>
<Message>UnknownError</Message>
<RowCount>1</RowCount>
<Success>true</Success>
</Results>
<Results>
<ColumnNames>["col1", "col2"]</ColumnNames>
<Rows>[{"col1": "value1", "col2":"value2"}]</Rows>
</Results>
<ErrorCode>UnknownError</ErrorCode>
<ErrorMessage>UnknownError</ErrorMessage>
<Success>true</Success>
JSON
format
{"RequestId":"FE8EE2F1-4880-46BC-A704-5CF63EAF9A04","Results":[{"Message":"UnknownError","RowCount":"1","Success":"true"},{"ColumnNames":"[\"col1\", \"col2\"]","Rows":"[{\"col1\": \"value1\", \"col2\":\"value2\"}]"}],"ErrorCode":"UnknownError","ErrorMessage":"UnknownError","Success":"true"}
Error codes
For a list of error codes, visit the API Error Center.