A special table type is used to handle database table lookups with optional caching in memory. All of the following column references may be either numeric (column index, starts at 0) or string (column name).
The table lookup only supports int, string and date types.
For MS SQL, the column type timestamp is not supported in tables accessed by Please refer to the Notes section in the 9. Database Functions page for details on allowed database data type. |
The sqlExec function is used when updating and inserting data into tables. It returns an integer value stating how many rows were updated/inserted. SQL errors will cause runtime errors (the workflow aborts).
int sqlExec ( string dbProfile, string sqlQuery ) |
Parameter | Description | |
---|---|---|
| Name of the database where the table resides, including folder name. | |
| SQL query to send to the database. Note that SQL statements must not end with ';'. Calls to stored procedures must be embedded in blocks.
| |
Returns | An integer equaling the number of rows updated or inserted. |
Returns a table that holds the result of a database query. SQL errors in the table lookup will cause runtime errors (workflow aborts).
table tableCreate ( string dbProfile, string sqlQuery boolean disableCommit) |
Parameter | Description | |
---|---|---|
| Name of the database where the table resides | |
| SQL query to send to the database. Note that SQL statements must not end with ';'. Only columns of type number, date and string are supported. | |
| An optional parameter to disable the commit statement from being performed at the end of every SQL transaction for this particular function. Setting this parameter to false will result in the commit statement to be performed at the end of every SQL transaction for this particular function. By default,
| |
Returns | A table |
To avoid performance problems, the table must be read from the database as seldom as possible. For instance, once for each workflow invocation.
|
Creates an index for one or several columns of a table. This will greatly increase the efficiency of subsequent tableLookup calls on these columns using the equality operator. If the column already has an index, this function has no effect.
An index will not be created unless there are at least five rows in the table. |
void tableCreateIndex ( table tableValue, int|string column1, ... int|string columnN ) |
Parameter | Description |
---|---|
| A table object |
| A column index (starting with 0 for the first column), or name for which to create an index. At least one column must be specified. |
Returns | Nothing |
|
The tableGet function returns the value of a table entry. The value is returned as an any object, which means the returned value is of the same type as the value extracted.
any tableGet ( table tableValue, int row, int|string column) |
Parameter | Description |
---|---|
| A table object |
| The row index. The first row is indexed 0 (zero). |
| Column index or name. The first column is indexed 0 (zero). |
Returns | Any depending on the column type |
The tableLookup function returns a table containing all the rows of the original table matching the specified column value(s). At least one pair of (column, operator, value) group must be specified.
table tableLookup ( table tableValue, int|string column1, string operator1, string|date|int value1, any value1a, //Optional (used only for "between" and "not between") ... int|column columnN, string operatorN, any valueN, any valueNa ) //Optional (used only for "between" and "not between") |
Parameter | Description |
---|---|
| A table object |
| Column index or name. The first column is indexed 0 (zero). |
| Operator specifying the range of the requested values. Possible operators are:
|
| Value(s) matching |
Returns | A table matching the query |
The following example looks for a specific entry in the in-memory table returned by the preceding tableCreate command.
|
When a column is of date type, the matching values must contain date, time, and timezone, as demonstrated in the example below. |
|
The tableRowCount function returns the number of rows in a table.
int tableRowCount (table tableValue ) |
Parameter | Description |
---|---|
| Table object |
Returns | An integer stating the number of rows found |