ballerina/sql package
Type Definitions
Type | Values | Description | |
---|---|---|---|
Direction | OUT | INOUT | IN | The direction of the parameter.
|
|
Param | |||
SQLType | VARCHAR | VARBINARY | TINYINT | TIMESTAMP | TIME | STRUCT | SMALLINT | REFCURSOR | REAL | NVARCHAR | NUMERIC | NCLOB | NCHAR | LONGVARCHAR | LONGVARBINARY | LONGNVARCHAR | INTEGER | FLOAT | DOUBLE | DECIMAL | DATETIME | DATE | CLOB | CHAR | BOOLEAN | BLOB | BIT | BINARY | BIGINT | ARRAY | The SQL Datatype of the parameter.
|
Records Summary
Record | Description | ||
---|---|---|---|
Parameter | CallParam represents a parameter for the SQL call action where OUT or INOUT parameter is required. |
||
PoolOptions | Represents the properties which are used to configure DB connection pool. |
Objects Summary
Object | Description | ||
---|---|---|---|
CallerActions | The Caller actions for SQL databases. |
Functions Summary
Return Type | Function and Description | ||
---|---|---|---|
close(CallerActions callerActions) The close action implementation for SQL connector to shutdown the connection pool. |
Global Variables
Name | Data Type | Description | |
---|---|---|---|
DIRECTION_IN | Direction | ||
DIRECTION_INOUT | Direction | ||
DIRECTION_OUT | Direction | ||
TYPE_ARRAY | SQLType | ||
TYPE_BIGINT | SQLType | ||
TYPE_BINARY | SQLType | ||
TYPE_BIT | SQLType | ||
TYPE_BLOB | SQLType | ||
TYPE_BOOLEAN | SQLType | ||
TYPE_CHAR | SQLType | ||
TYPE_CLOB | SQLType | ||
TYPE_DATE | SQLType | ||
TYPE_DATETIME | SQLType | ||
TYPE_DECIMAL | SQLType | ||
TYPE_DOUBLE | SQLType | ||
TYPE_FLOAT | SQLType | ||
TYPE_INTEGER | SQLType | ||
TYPE_LONGNVARCHAR | SQLType | ||
TYPE_LONGVARBINARY | SQLType | ||
TYPE_LONGVARCHAR | SQLType | ||
TYPE_NCHAR | SQLType | ||
TYPE_NCLOB | SQLType | ||
TYPE_NUMERIC | SQLType | ||
TYPE_NVARCHARR | SQLType | ||
TYPE_REAL | SQLType | ||
TYPE_REFCURSOR | SQLType | ||
TYPE_SMALLINT | SQLType | ||
TYPE_STRUCT | SQLType | ||
TYPE_TIME | SQLType | ||
TYPE_TIMESTAMP | SQLType | ||
TYPE_TINYINT | SQLType | ||
TYPE_VARBINARY | SQLType | ||
TYPE_VARCHAR | SQLType |
public type Parameter
CallParam represents a parameter for the SQL call action where OUT or INOUT parameter is required.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
sqlType | SQLType | The data type of the corresponding SQL parameter |
|
value | any | Value of paramter pass into the SQL query |
|
direction | Direction | Direction of the SQL Parameter OUT, or INOUT - Default value is IN |
|
recordType | typedesc | In case of OUT direction, if the sqlType is REFCURSOR, this represents the record type to map a result row |
public type PoolOptions
Represents the properties which are used to configure DB connection pool.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
connectionInitSql | string | SQL statement that will be executed after every new connection creation before adding it to the pool |
|
dataSourceClassName | string | Name of the DataSource class provided by the JDBC driver |
|
autoCommit | boolean | true | Auto-commit behavior of connections returned from the pool |
isXA | boolean | false | Whether Connections are used for a distributed transaction |
maximumPoolSize | int | -1 | Maximum size that the pool is allowed to reach, including both idle and in-use connections |
connectionTimeout | int | -1 | Maximum number of milliseconds that a client will wait for a connection from the pool |
idleTimeout | int | -1 | Maximum amount of time that a connection is allowed to sit idle in the pool |
minimumIdle | int | -1 | Minimum number of idle connections that pool tries to maintain in the pool |
maxLifetime | int | -1 | Maximum lifetime of a connection in the pool |
validationTimeout | int | -1 | Maximum amount of time that a connection will be tested for aliveness |
public function close(CallerActions callerActions)
The close action implementation for SQL connector to shutdown the connection pool.
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
callerActions | CallerActions |
public type CallerActions object
The Caller actions for SQL databases.
-
<CallerActions> call(string sqlQuery, typedesc[] recordType) returns (table[] | error)
The call action implementation for SQL connector to invoke stored procedures/functions.
Parameter Name Data Type Default Value Description sqlQuery string SQL statement to execute
recordType typedesc[] Array of record types of the returned tables if there is any
Return Type Description table[] | error A
table[]
if there are tables returned by the call action and else nill,error
will be returned if there is any error -
<CallerActions> select(string sqlQuery, typedesc recordType) returns (table | error)
The select action implementation for SQL connector to select data from tables.
Parameter Name Data Type Default Value Description sqlQuery string SQL query to execute
recordType typedesc Type of the returned table
Return Type Description table | error A
table
returned by the sql query statement elseerror
will be returned if there is any error -
<CallerActions> update(string sqlQuery) returns (int | error)
The update action implementation for SQL connector to update data and schema of the database.
Parameter Name Data Type Default Value Description sqlQuery string SQL statement to execute
Return Type Description int | error int
number of rows updated by the statement and elseerror
will be returned if there is any error -
<CallerActions> batchUpdate(string sqlQuery) returns (int[] | error)
The batchUpdate action implementation for SQL connector to batch data insert.
Parameter Name Data Type Default Value Description sqlQuery string SQL statement to execute
Return Type Description int[] | error An
int[]
array of updated row count by each of statements in batch and elseerror
will be returned if there is any error -
<CallerActions> updateWithGeneratedKeys(string sqlQuery, string[] keyColumns) returns ((int,string[]) | error)
The updateWithGeneratedKeys action implementation for SQL connector which returns the auto generated keys during the update action.
Parameter Name Data Type Default Value Description sqlQuery string SQL statement to execute
keyColumns string[] Names of auto generated columns for which the auto generated key values are returned
Return Type Description (int,string[]) | error A
Tuple
will be returned and would represent updated row count during the query exectuion, aray of auto generated key values during the query execution, in order. Elseerror
will be returned if there is any error. -
<CallerActions> getProxyTable(string tableName, typedesc recordType) returns (table | error)
The getProxyTable action implementation for SQL connector which acts as a proxy for a database table that allows performing select/update operations over the actual database table.
Parameter Name Data Type Default Value Description tableName string The name of the table to be retrieved
recordType typedesc The record type of the returned table
Return Type Description table | error