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?>
Isolated Function
Remote Function

Executes the query, which may return multiple results.

Parameters

  • rowType typedesc<record {}> (default <>)
  • The typedesc of the record to which the result needs to be returned

Return Type

(stream<rowType, Error?>)

Stream of records in the rowType type

queryRow

function queryRow(ParameterizedQuery sqlQuery, typedesc<anydata> returnType) returns returnType | Error
Isolated Function
Remote Function

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

  • 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

Return Type

(returnType | Error)

Result in the returnType type or an sql:Error

execute

function execute(ParameterizedQuery sqlQuery) returns ExecutionResult | Error
Isolated Function
Remote Function

Executes the SQL query. Only the metadata of the execution is returned (not the results from the query).

Parameters

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
Isolated Function
Remote Function

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

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
Isolated Function
Remote Function

Executes an SQL query, which calls a stored procedure. This may or may not return results.

Parameters

  • 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

close

function close() returns Error?
Isolated Function

Closes the SQL client and shuts down the connection pool.

Return Type

(Error?)

Possible sql:Error when closing the client