Skip to main content

statements

Creates, updates, deletes, gets or lists a statements resource.

Overview

Namestatements
TypeResource
Idsnowflake.sqlapi.statements

Fields

The following fields are returned by SELECT queries:

The statement was executed successfully, and the response includes any data requested.

NameDatatypeDescription
codestring (example: 000123)
createdOninteger (int64)Timestamp that specifies when the statement execution started.‌ The timestamp is expressed in milliseconds since the epoch.‌
dataarrayResult set data.
messagestring (example: successfully executed)
resultSetMetaDataobject
sqlStatestring (example: 42601)
statementHandlestring (uuid) (example: 536fad38-b564-4dc5-9892-a4543504df6c)
statementStatusUrlstring (uri)
statsobjectthese stats might not be available for each request.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_statement_statusselectendpointChecks the status of the execution of the statement with the specified statement handle. If the statement was executed successfully, the operation returns the requested partition of the result set.
submit_statementinsertendpointSubmits one or more statements for execution. You can specify that the statement should be executed asynchronously.
cancel_statementdeleteendpointCancels the execution of the statement with the specified statement handle.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
endpointstringOrganization and Account Name (default: orgid-acctid)

SELECT examples

Checks the status of the execution of the statement with the specified statement handle. If the statement was executed successfully, the operation returns the requested partition of the result set.

SELECT
code,
createdOn,
data,
message,
resultSetMetaData,
sqlState,
statementHandle,
statementStatusUrl,
stats
FROM snowflake.sqlapi.statements
WHERE endpoint = '{{ endpoint }}' -- required;

INSERT examples

Submits one or more statements for execution. You can specify that the statement should be executed asynchronously.

INSERT INTO snowflake.sqlapi.statements (
data__statement,
data__timeout,
data__database,
data__schema,
data__warehouse,
data__role,
data__bindings,
data__parameters,
endpoint
)
SELECT
'{{ statement }}',
{{ timeout }},
'{{ database }}',
'{{ schema }}',
'{{ warehouse }}',
'{{ role }}',
'{{ bindings }}',
'{{ parameters }}',
'{{ endpoint }}'
RETURNING
code,
createdOn,
data,
message,
resultSetMetaData,
sqlState,
statementHandle,
statementStatusUrl,
stats
;

DELETE examples

Cancels the execution of the statement with the specified statement handle.

DELETE FROM snowflake.sqlapi.statements
WHERE endpoint = '{{ endpoint }}' --required;