Module sql
API
Declarations
Definitions
ballerina/sql Ballerina library
Functions
arrayFlattenQuery
function arrayFlattenQuery(Value[] values) returns ParameterizedQueryJoins the parameters in the array with the , delimiter into an sql:ParameterizedQuery.
Parameters
- values Value[] - An array of
sql:Valuevalues
Return Type
- ParameterizedQuery - An
sql:ParameterizedQuery
generateApplicationErrorStream
Generates a stream consisting of sql:Error elements.
Parameters
- message string - Error message used to initialise an
sql:Error
getGlobalConnectionPool
function getGlobalConnectionPool() returns ConnectionPoolReturns the global connection pool.
Return Type
- ConnectionPool - The connection pool
queryConcat
function queryConcat(ParameterizedQuery... queries) returns ParameterizedQueryConcatenates all provided sql:ParameterizedQuerys into a single sql:ParameterizedQuery.
Parameters
- queries ParameterizedQuery... - Set of
sql:ParameterizedQueryqueries
Return Type
- ParameterizedQuery - An
sql:ParameterizedQuery
Classes
sql: ArrayOutParameter
Represents Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: ArrayValue
Represents SQL ArrayValue type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
Deprecated
This ArrayValue class deprecated by introducing the a new ArrayValueType type.
sql: BigIntArrayOutParameter
Represents BigInt Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BigIntArrayValue
Represents SQL BigInt array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int?[] - Value of the parameter
sql: BigIntOutParameter
Represents BigInt Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BigIntValue
Represents SQL BigInt type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int? - Value of the parameter
sql: BinaryArrayOutParameter
Represents Binary Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BinaryArrayValue
Represents SQL Boolean array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]?[]|ReadableByteChannel[] - Value of the parameter
sql: BinaryOutParameter
Represents Binary Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BinaryValue
Represents SQL Binary type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]|ReadableByteChannel? - Value of the parameter
sql: BitArrayOutParameter
Represents Bit Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BitArrayValue
Represents SQL Bit array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: BitOutParameter
Represents Bit Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BitValue
Represents SQL Bit type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: BlobOutParameter
Represents Blob Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BlobValue
Represents SQL Blob type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]|ReadableByteChannel? - Value of the parameter
sql: BooleanArrayOutParameter
Represents Boolean Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BooleanArrayValue
Represents SQL Boolean array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value boolean?[] - Value of the parameter
sql: BooleanOutParameter
Represents Boolean Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: BooleanValue
Represents SQL Boolean type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value boolean? - Value of the parameter
sql: CharArrayOutParameter
Represents Char Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned Char SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: CharArrayValue
Represents SQL Char array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[] - Value of the parameter
sql: CharOutParameter
Represents Char Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned Char SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: CharValue
Represents SQL Char type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string? - Value of the parameter
sql: ClobOutParameter
Represents Clob Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: ClobValue
Represents SQL Clob type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value ReadableCharacterChannel|string? - Value of the parameter
sql: CursorOutParameter
Represents the Cursor Out Parameters in sql:ParameterizedCallQuery.
get
Parses returned SQL result set values to a ballerina stream value.
Parameters
- rowType typedesc<record {}> (default <>) - The
typedescof the record to which the result needs to be returned
sql: DateArrayOutParameter
Represents Date Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DateArrayValue
Represents SQL Date array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[]|Date?[] - Value of the parameter
sql: DateOutParameter
Represents Date Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DateTimeArrayOutParameter
Represents DateTime Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DateTimeArrayValue
Represents SQL DateTime array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[]|Civil?[] - Value of the parameter
sql: DateTimeOutParameter
Represents DateTime Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DateTimeValue
Represents SQL DateTime type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string|Civil? - Value of the parameter
sql: DateValue
Represents SQL Date type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string|Date? - Value of the parameter
sql: DecimalArrayOutParameter
Represents Decimal Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DecimalArrayValue
Represents SQL Decimal array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: DecimalOutParameter
Represents Decimal Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DecimalValue
Represents SQL Decimal type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: DoubleArrayOutParameter
Represents Double Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DoubleArrayValue
Represents SQL Double array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: DoubleOutParameter
Represents Double Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: DoubleValue
Represents SQL Double type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: FloatArrayOutParameter
Represents Float Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: FloatArrayValue
Represents SQL Float array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: FloatOutParameter
Represents Float Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: FloatValue
Represents SQL Float type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: InOutParameter
Represents SQL InOutParameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: IntegerArrayOutParameter
Represents Integer Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: IntegerArrayValue
Represents SQL Integer array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int?[] - Value of the parameter
sql: IntegerOutParameter
Represents Integer Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: IntegerValue
Represents SQL Integer type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int? - Value of the parameter
sql: NCharOutParameter
Represents NChar Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NCharValue
Represents SQL NChar type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string? - Value of the parameter
sql: NClobOutParameter
Represents NClob Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NClobValue
Represents SQL NClob type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value ReadableCharacterChannel|string? - Value of the parameter
sql: NumericArrayOutParameter
Represents Numeric Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NumericArrayValue
Represents SQL Numeric array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: NumericOutParameter
Represents Numeric Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NumericValue
Represents SQL Numeric type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: NVarcharArrayOutParameter
Represents NVarchar Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NVarcharArrayValue
Represents SQL NVarchar type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[] - Value of the parameter
sql: NVarcharOutParameter
Represents NVarchar Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: NVarcharValue
Represents SQL NVarchar type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string? - Value of the parameter
sql: ProcedureCallResult
Represents the results from the call method holding the returned results or metadata of the query execution.
getNextQueryResult
Updates executionResult or queryResult field with the succeeding result in the result list. This will also close the current
result when called. The close method must be called once all the results are processed.
close
function close() returns Error?Releases the associated resources such as the database connection, results, etc. This method must be called once all results are processed.
Return Type
- Error? - An
sql:Errorif any error occurred while cleanup
Fields
- executionResult ExecutionResult?(default ()) - Summary of the query execution
- customResultIterator CustomResultIterator? - Any custom result iterator to be used to override the default behaviour
sql: RealArrayOutParameter
Represents Real Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: RealArrayValue
Represents SQL Real array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: RealOutParameter
Represents Real Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: RealValue
Represents SQL Real type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
sql: RefOutParameter
Represents Ref Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: RefValue
Represents SQL Ref type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value record {}? - Value of the parameter
sql: ResultIterator
The result iterator used to iterate results in stream returned from query function.
next
function next() returns record {| value record {} |}|Error?close
function close() returns Error?Fields
- customResultIterator CustomResultIterator? - Any custom result iterator to be used to override the default behaviour
sql: RowOutParameter
Represents Row Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: RowValue
Represents SQL Row type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]? - Value of the parameter
sql: SmallIntArrayOutParameter
Represents SmallInt Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: SmallIntArrayValue
Represents SQL SmallInt array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int?[] - Value of the parameter
sql: SmallIntOutParameter
Represents SmallInt Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: SmallIntValue
Represents SQL SmallInt type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value int? - Value of the parameter
sql: StructOutParameter
Represents Struct Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: StructValue
Represents SQL Struct type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value record {}? - Value of the parameter
sql: TextOutParameter
Represents Text Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TextValue
Represents SQL Text type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value ReadableCharacterChannel|string? - Value of the parameter
sql: TimeArrayOutParameter
Represents Time Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimeArrayValue
Represents SQL Time array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[]|TimeOfDay?[] - Value of the parameter
sql: TimeOutParameter
Represents Time Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimestampArrayOutParameter
Represents Timestamp Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimestampArrayValue
Represents SQL Timestamp array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[]|Utc?[] - Value of the parameter
sql: TimestampOutParameter
Represents Timestamp Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimestampValue
Represents SQL Timestamp type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string|Utc? - Value of the parameter
sql: TimestampWithTimezoneArrayOutParameter
Represents Timestamp with Timezone Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimestampWithTimezoneOutParameter
Represents Timestamp with Timezone Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimeValue
Represents SQL Time type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string|TimeOfDay? - Value of the parameter
sql: TimeWithTimezoneArrayOutParameter
Represents Time With Timezone Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: TimeWithTimezoneOutParameter
Represents Time With Timezone Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: VarBinaryArrayOutParameter
Represents VarBinary Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: VarBinaryArrayValue
Represents SQL Boolean array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]?[]|ReadableByteChannel[] - Value of the parameter
sql: VarBinaryOutParameter
Represents VarBinary Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: VarBinaryValue
Represents SQL VarBinary type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value byte[]|ReadableByteChannel? - Value of the parameter
sql: VarcharArrayOutParameter
Represents Varchar Array Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: VarcharArrayValue
Represents SQL Varchar array type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string?[] - Value of the parameter
sql: VarcharOutParameter
Represents Varchar Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: VarcharValue
Represents SQL Varchar type parameter in sql:ParameterizedQuery.
Fields
- Fields Included from *TypedValue
- value anydata||anydata[]|[]
- value string? - Value of the parameter
sql: XMLOutParameter
Represents XML Out Parameter in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
Constants
sql: EXECUTION_FAILED
Constant indicating that the specific batch statement failed.
sql: SUCCESS_NO_INFO
Constant indicating that the specific batch statement executed successfully but that the count of affected rows is unavailable.
Enums
sql: ColumnRetrievalOptions
Members
sql: ParameterMode
Represents the mode of the parameter for a routine.
Members
sql: ReferentialRule
Represents the type of actions that would be taken on delete or on update for foreign key constraints.
Members
sql: RoutineType
Represents the type of the routine retrieved through the getRoutineInfo function.
Members
sql: TableType
Represents the type of the table/view retrieved through the getTableInfo function.
Members
Annotations
sql: Column
The Annotation used to specify which database column matches the Typed record field.
Configurables
Records
sql: BatchExecuteErrorDetail
Represents the properties belonging to an sql:BatchExecuteError.
Fields
- errorCode int - SQL error code
- sqlState string? - SQL state
- executionResults ExecutionResult[] - Metadata of the query executions
sql: CheckConstraint
Represents a check constraint.
Fields
- name string - The name of the constraint
- clause string - The actual text of the SQL definition statement
sql: ColumnConfig
Defines the database column name which matches the record field. The default value is the record field name.
Fields
- name string - The database column name
sql: ColumnDefinition
Represents a column in a table.
Fields
- name string - The name of the column
- 'type string - The SQL data-type associated with the column
- defaultValue anydata? - The default value of the column
- nullable boolean - Whether the column is nullable
- referentialConstraints? ReferentialConstraint[] - Referential constraints (foreign key relationships) associated with the column
sql: ConnectionPool
Represents the properties, which are used to configure a DB connection pool. Default values of the fields can be set through the configuration API.
Fields
- maxOpenConnections int(default maxOpenConnections) - The maximum number of open connections that the pool is allowed to have.
Includes both idle and in-use connections. The default value is 15. This can be changed through
the configuration API with the
ballerina.sql.maxOpenConnectionskey
- maxConnectionLifeTime decimal(default maxConnectionLifeTime) - The maximum lifetime (in seconds) of a connection in the pool. The default value is 1800
seconds (30 minutes). A value of 0 indicates an unlimited maximum lifetime (infinite lifetime).
The minimum allowed value is 30 seconds. This can be changed through the configuration API
with the
ballerina.sql.maxConnectionLifeTimekey.
- minIdleConnections int(default minIdleConnections) - The minimum number of idle connections that the pool tries to maintain. The default value
is the same as
maxOpenConnectionsand it can be changed through the configuration API with theballerina.sql.minIdleConnectionskey
sql: DatabaseErrorDetail
Represents the properties belonging to an sql:DatabaseError.
Fields
- errorCode int - SQL error code
- sqlState string? - SQL state
sql: ExecutionResult
Metadata of the query execution.
Fields
- affectedRowCount int? - Number of rows affected by the execution of the query. It may be one of the following,
(1) A number greater than or equal to zero, the count of affected rows after the successful execution of the query
(2) A value of theSUCCESS_NO_INFO, the count of affected rows is unknown after the successful execution of the query
(3) A value of theEXECUTION_FAILED, the query execution failed
sql: ParameterDefinition
Represents a routine parameter.
Fields
- mode ParameterMode - The mode of the parameter (IN, OUT, INOUT)
- name string - The name of the parameter
- 'type string -
sql: ReferentialConstraint
Represents a referential constraint (foriegn key constraint).
Fields
- name string - The name of the constraint
- tableName string - The name of the table which contains the referenced column
- columnName string - The name of the referenced column
- updateRule ReferentialRule - The action taken when an update statement violates the constraint
- deleteRule ReferentialRule - The action taken when a delete statement violates the constraint
sql: RoutineDefinition
Represents a routine.
Fields
- name string - The name of the routine
- 'type RoutineType - The type of the routine (procedure or function)
- returnType string? - If the routine returns a value, the return data-type. Else ()
- parameters ParameterDefinition[] - The parameters associated with the routine
sql: TableDefinition
Represents a table in the database.
Fields
- name string - The name of the table
- 'type TableType - Whether the table is a base table or a view
- columns? ColumnDefinition[] - The columns included in the table
- checkConstraints? CheckConstraint[] - Check constraints associated with the table
Errors
sql: ApplicationError
Represents an error originating from application-level configurations.
sql: BatchExecuteError
Represents an error that occurs during the execution of batch queries.
sql: ConversionError
Represents an error that occurs when a query retrieves a result that is corrupted and cannot be converted to the expected type.
sql: DatabaseError
Represents an error caused by an issue related to database accessibility, erroneous queries, constraint violations, database resource clean-up, and other similar scenarios.
sql: DataError
Represents an error that occurs during the processing of the parameters or returned results.
sql: Error
Defines the generic error type for the sql module.
sql: FieldMismatchError
Represents an error that occurs when a query retrieves a result that cannot be mapped to the expected record type.
sql: NoRowsError
Represents an error that occurs when a query retrieves does not retrieve any rows when at least one row is expected.
sql: TypeMismatchError
Represents an error that occurs when a query retrieves a result that differs from the supported result type.
sql: UnsupportedTypeError
Represents an error that occurs when an unsupported parameter type is added to the query.
Object types
sql: Client
Represents an SQL client.
query
function query(ParameterizedQuery sqlQuery, typedesc<record {}> rowType) returns stream<rowType, Error?>Executes the query, which may return multiple results. When processing the stream, make sure to consume all fetched data or close the stream.
Parameters
- sqlQuery ParameterizedQuery - The SQL query
- rowType typedesc<record {}> (default <>) - The
typedescof the record to which the result needs to be returned
queryRow
function queryRow(ParameterizedQuery sqlQuery, typedesc<anydata> returnType) returns returnType|ErrorExecutes 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
typedescof 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
returnTypetype or ansql:Error
execute
function execute(ParameterizedQuery sqlQuery) returns ExecutionResult|ErrorExecutes 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:ExecutionResultor ansql:Error
batchExecute
function batchExecute(ParameterizedQuery[] sqlQueries) returns ExecutionResult[]|ErrorExecutes 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 ansql:Error
call
function call(ParameterizedCallQuery sqlQuery, typedesc<record {}>[] rowTypes) returns ProcedureCallResult|ErrorExecutes an SQL query, which calls a stored procedure. This may or may not
return results. Once the results are processed, the close method on sql:ProcedureCallResult must be called.
Parameters
- sqlQuery ParameterizedCallQuery - The SQL query
- rowTypes typedesc<record {}>[] (default []) -
typedescarray 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 ansql:Error
close
function close() returns Error?Closes the SQL client and shuts down the connection pool. The client must be closed only at the end of the application lifetime (or closed for graceful stops in a service).
Return Type
- Error? - Possible
sql:Errorwhen closing the client
sql: CustomResultIterator
The iterator for the stream returned in the query function to be used to override the default behavior of the sql:ResultIterator.
nextResult
function nextResult(ResultIterator iterator) returns record {}|Error?Parameters
- iterator ResultIterator -
getNextQueryResult
function getNextQueryResult(ProcedureCallResult callResult) returns boolean|ErrorParameters
- callResult ProcedureCallResult -
sql: OutParameter
Represents the generic OUT Parameters in sql:ParameterizedCallQuery.
get
function get(typedesc<anydata> typeDesc) returns typeDesc|ErrorParses returned Char SQL value to a ballerina value.
Parameters
- typeDesc typedesc<anydata> (default <>) - The
typedescof the type to which the result needs to be returned
Return Type
- typeDesc|Error - The result in the
typeDesctype, or ansql:Error
sql: ParameterizedCallQuery
The object constructed through backtick surrounded strings. Dynamic parameters of sql:Parameter type can be indicated using ${<variable name>}
such as `The sql:ParameterizedQuery is ${variable_name}`.
This validates the parameter types during the query execution.
Fields
- Fields Included from *RawTemplate
- strings (string[] & readonly) - The separated parts of the SQL query
- insertions Parameter[] - The values of the parameters that should be filled in between the parts
sql: ParameterizedQuery
The object constructed through backtick surrounded strings. Dynamic parameters of sql:Value type can be indicated using ${<variable name>}
such as `The sql:ParameterizedQuery is ${variable_name}`.
This validates the parameter types during the query execution.
Fields
- Fields Included from *RawTemplate
- strings (string[] & readonly) - The separated parts of the SQL query
- insertions Value[] - The values of the parameters that should be filled in between the parts
sql: SchemaClient
Represents an SQL metadata client.
listTables
Retrieves all tables in the database.
getTableInfo
function getTableInfo(string tableName, ColumnRetrievalOptions include) returns TableDefinition|ErrorRetrieves information relevant to the provided table in the database.
Parameters
- tableName string - The name of the table
- include ColumnRetrievalOptions (default COLUMNS_ONLY) - Options on whether columnar and constraint related information should be fetched.
If
NO_COLUMNSis provided, then no information related to columns will be retrieved. IfCOLUMNS_ONLYis provided, then columnar information will be retrieved, but not constraint related information. IfCOLUMNS_WITH_CONSTRAINTSis provided, then columar information along with constraint related information will be retrieved
Return Type
- TableDefinition|Error - An 'sql:TableDefinition' with the relevant table information or an
sql:Error
listRoutines
Retrieves all routines in the database.
getRoutineInfo
function getRoutineInfo(string name) returns RoutineDefinition|ErrorRetrieves information relevant to the provided routine in the database.
Parameters
- name string - The name of the routine
Return Type
- RoutineDefinition|Error - An 'sql:RoutineDefinition' with the relevant routine information or an
sql:Error
close
function close() returns Error?Closes the SQL metadata client.
Return Type
- Error? - Possible
sql:Errorwhen closing the client
sql: TypedValue
Generic type that can be passed to sql:ParameterizedQuery to represent parameters in the SQL query.
Fields
- value anydata|object {}|anydata[]|object {}[]? - Value of the parameter
Union types
sql: Value
Value
Generic type of ballerina basic types that can be passed to sql:ParameterizedQuery to represent parameters in the SQL query.
sql: Parameter
Parameter
Generic type that can be passed to sql:ParameterizedCallQuery to indicate procedure/function parameters.
Import
import ballerina/sql;Metadata
Released date: 11 months ago
Version: 1.15.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.11.0-20241209-162400-0c015833
GraalVM compatible: Yes
Pull count
Total: 52
Current verison: 0
Weekly downloads
Keywords
database
client
network
SQL
RDBMS
Contributors
Dependencies