Object type: Client
Represents an SQL client.
Methods
query | Executes the query, which may return multiple results. |
queryRow | Executes the query, which is expected to return at most one row of the result. |
execute | Executes the SQL query. |
batchExecute | Executes the SQL query with multiple sets of parameters in a batch. |
call | Executes an SQL query, which calls a stored procedure. |
close | Closes the SQL client and shuts down the connection pool. |
query
function query(ParameterizedQuery sqlQuery, typedesc<record {}> rowType) returns stream<rowType, Error?>
Executes the query, which may return multiple results.
Parameters
- sqlQuery ParameterizedQuery
The SQL query
- rowType typedesc<record {}> (default <>)
The typedesc
of the record to which the result needs to be returned
queryRow
function queryRow(ParameterizedQuery sqlQuery, typedesc<anydata> returnType) returns returnType | Error
Executes the query, which is expected to return at most one row of the result.
If the query does not return any results, sql:NoRowsError
is returned.
Parameters
- sqlQuery ParameterizedQuery
The SQL query
- returnType typedesc<anydata> (default <>)
The typedesc
of the record to which the result needs to be returned.
It can be a basic type if the query result contains only one column
execute
function execute(ParameterizedQuery sqlQuery) returns ExecutionResult | Error
Executes the SQL query. Only the metadata of the execution is returned (not the results from the query).
Parameters
- sqlQuery ParameterizedQuery
The SQL query
Return Type
(ExecutionResult | Error)Metadata of the query execution as an sql:ExecutionResult
or an sql:Error
batchExecute
function batchExecute(ParameterizedQuery[ ] sqlQueries) returns ExecutionResult[ ] | Error
Executes the SQL query with multiple sets of parameters in a batch. Only the metadata of the execution is returned (not the results from the query).
If one of the commands in the batch fails, an sql:BatchExecuteError
will be returned. However, the driver may
or may not continue to process the remaining commands in the batch after a failure.
Parameters
- sqlQueries ParameterizedQuery[ ]
The SQL query with multiple sets of parameters
Return Type
(ExecutionResult[ ] | Error)Metadata of the query execution as an sql:ExecutionResult[]
or an sql:Error
call
function call(ParameterizedCallQuery sqlQuery, typedesc<record {}>[ ] rowTypes) returns ProcedureCallResult | Error
Executes an SQL query, which calls a stored procedure. This may or may not return results.
Parameters
- sqlQuery ParameterizedCallQuery
The SQL query
- rowTypes typedesc<record {}>[ ] (default [])
typedesc
array of the records to which the results need to be returned
Return Type
(ProcedureCallResult | Error)Summary of the execution and results are returned in an sql:ProcedureCallResult
, or an sql:Error