class query

superclass(es) object
subclass(es) -
description The query class is for executing SQL statements and browsing through the result set of a query.
remarks This class is located in the file db.txt.
see also dbSession - database

tasks

The query class is used to have SQL statements executed by a database and to browse the result set of the query statement (if the SQL statement has a result set). Before a query instance can be used it must be associated to a database instance, this is done by calling the method putDatabase/2.

If a SQL statement is executed or prepared and there is an error then a more specific error code is assigned to an output variable. The predicate dberror/2 can translate an error code to an error message.

If a query instance is used to execute a SQL 'SELECT' statement a result set is created, this result set contains all the rows selected by the SQL statement. The result set can be browsed using the same query instance. To determine if the query has a result set the method isOpen/1 can be called. A result set can be closed by the close/0 or close/1 methods. After a result has been closed the same query instance can be used again for executing SQL statements and browsing the result set.

Information about the columns in the result set of query instance can be retrieved by the methods numColumns/1, columns/2, columnInfo/8 and columnInfoName/8.

see also: Retrieving results Date and time formatting Parameters Long fields Procedures Catalog methods

methods

putDatabase(Database, Output)

func Assign a database instance to the query instance. Before a query instance can be used it must be connected to a database instance. The query instance copies the date and time format strings of the database instance.
pre The variable Database must refer to an instance of the class database.
post If the query instance was successfully connected to the database instance then true was assigned to Output, if there was an error then false was assigned to Output. The time and date format strings of the query instance are identical to the format strings of the database instance.

execute(SQL, Output, ErrorCode)

func Execute the SQL statement, the statement cannot contain any parameters. The SQL statement is immediately executed by the database.
pre The variable SQL must contain a string.
post If there was no error executing the SQL statement then true was assigned to Output, if there was an error then false was assigned to Output and a more specific error code value was assigned to the variable ErrorCode. To translate the error code to an error message use the predicate dberror/2.
If the SQL statement was successful and it was a SELECT statement a result set can be returned.

close

func Close the result set of the query instance.
pre TRUE
post If the query had a result then it was closed.

close(Output)

func Close the result set of the query instance.
pre TRUE
post If the query had a result and it was successfully closed then was true assigned to Output, else if there was an error closing the result set then false was assigned to Output.

isOpen(Output)

func Determine if the result set of the query instance is open.
pre TRUE
post If the query had a result and it was open then was true assigned to Output, else if there was no result set then false was assigned to Output.

numColumns(Output)

func Determine the number of columns in the result set of the query instance.
pre TRUE
post The number of columns in the result of the column was assigned to Output. If no result set was open then 0 was assigned to Output.

columns(Columns, Output)

func Create a list of the names of the columns in the result set.
pre TRUE
post If the query instance has a result set a list with all the names of the columns in the result set were assigned to the variable Columns. If a list was successfully created then true was assigned to the variable Output, else if there was an error creating the list then false was assigned to Output, the variable Columns is then assigned an empty list.

columnInfo(Pos, Name, DataType, Size, DisplaySize, Decimals, Nullable, Output)

func Get various properties about a single column like; the name of the column (Name), the data type of the column (DataType), the size in bytes of the column (Size), the display size of the column (DisplaySize), the number of decimals if it is a floating point column (Decimals), if the value of the fields in the column may be NULL (Nullable).
The variable Pos determines which column is queried, the index number of the first column is 0.
pre The variable Pos must contain an integer (not smaller than 0).
post If information about the column was successfully queried then true was assigned to the variable Output, if there was an error retrieving information then false was assigned to Output.

columnInfoName(Name, Pos, DataType, Size, DisplaySize, Decimals, Nullable, Output)

func Get various properties about a single column like; the position of a column (Pos), the data type of the column (DataType), the size in bytes of the column (Size), the display size of the column (DisplaySize), the number of decimals if it is a floating point column (Decimals), if the value of the fields in the column may be NULL (Nullable).
The search for a column with the same name is case sensitive.
pre The variable Name must contain a string.
post If information about the column was successfully queried then true was assigned to the variable Output, if there was an error retrieving information then false was assigned to Output.

nextRow(Output, Finished)

func Go to the next row in the result set of a query. The initial position of the cursor after executing a query is in front of the first row of the result set.
pre A result set must be open.
post If the cursor in the result was successfully moved to the next row then true was assigned to Output, if there was an error moving the cursor then was false assigned to Output. If the last record of the result was reached the Finished parameter was assigned true, else it was assigned false.

nextRowRedo(Output, Finished)

func Go to the next row in the result set of a query. The initial position of the cursor after executing a query is in front of the first row of the result set. This predicate can be redone while failing, so it can be used in a fail driven loop.
pre A result set must be open.
post If the cursor in the result was successfully moved to the next row then true was assigned to Output, if there was an error moving the cursor then was false assigned to Output. If the last record of the result was reached the Finished parameter was assigned true, else it was assigned false.

fetchCurRow(OutCols, Output)

func Retrieve the values of all the columns in the current row of the result set. A list of all the values is created.
pre A result set must be open.
post If the values were retrieved and assigned to the variable OutCols then true was assigned to Output, if there was an error retrieving the values or creating a list of values then was false assigned to Output.

fetchNextRow(OutCols, Finished, Output)

func Go to the next record in the result set and retrieve the values of all the columns in the current row of the result set. A list of all the values is created. The initial position of the cursor after executing a query is in front of the first row of the result set.
pre A result set must be open.
post If the cursor was moved to the next record in the result set and the values for the columns were retrieved and assigned to the variable OutCols then true was assigned to Output, if there was an error retrieving the values or creating a list of values then was false assigned to Output. If the last record of the result was reached the Finished parameter was assigned true, else it was assigned false.

fetchNextRowRedo(OutCols, Finished, Output)

func Go to the next record in the result set and retrieve the values of all the columns in the current row of the result set. A list of all the values is created. The initial position of the cursor after executing a query is in front of the first row of the result set. This predicate can be redone while failing, so it can be used in a fail driven loop.
pre A result set must be open.
post If the cursor was moved to the next record in the result set and the values for the columns were retrieved and assigned to the variable OutCols then true was assigned to Output, if there was an error retrieving the values or creating a list of values then was false assigned to Output. If the last record of the result was reached the Finished parameter was assigned true, else it was assigned false.

fetchCurColPos(Pos, OutValue, Output)

func Retrieve the value of a column of the current record in the result set. The value of the Pos variable determines of which column the value is retrieved. The index of the first column is 0.
pre A result set must be open and the variable Pos must contain an integer.
post If the value was retrieved and assigned to the variable OutValue then true was assigned to Output, if there was an error retrieving the value then false was assigned to Output.

fetchCurColName(Name, OutValue, Output)

func Retrieve the value of a column of the current record in the result set. The value of the Name variable determines of which column the value is retrieved.
pre A result set must be open and the variable Name must contain a string.
post If the value was retrieved and assigned to the variable OutValue then true was assigned to Output, if there was an error retrieving the value then false was assigned to Output.

prevRow(Output, Finished)

func Move the cursor of the query a row back. Default cursors can only be moved forward, to make a cursor scroll to previous rows see putScrollable/2.
pre A result set must be open and the cursor must be able to move backwards.
post If the cursor was moved to the previous row then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output. If the cursor was moved in front of the first record of the result set then true was assigned to Finished, else was false assigned.

prevRowRedo(Output, Finished)

func Move the cursor of the query a row back. Default cursors can only be moved forward, to make a cursor scroll to previous rows see putScrollable/2. This predicate can be redone while failing, so it can be used in a fail driven loop.
pre A result set must be open and the cursor must be able to move backwards.
post If the cursor was moved to the previous row then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output. If the cursor was moved in front of the first record of the result set then true was assigned to Finished, else was false assigned.

firstRow(Output)

func Move the cursor to the first row of the result set. Default cursors cannot be moved to the first record, to make a cursor do this see putScrollable/2.
pre A result set must be open and the cursor must be able to move to the first record.
post If the cursor was moved to the first record then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output.

lastRow(Output)

func Move the cursor to the last row of the result set. Default cursors cannot be moved to the last record, to make a cursor do this see putScrollable/2.
pre A result set must be open and the cursor must be able to move to the last record.
post If the cursor was moved to the last record then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output.

absolute(Num, Output)

func Move the cursor a number of rows up from the first row of the result set. Default cursors cannot be moved by this method, to make a cursor do this see putScrollable/2. The index of the first record in the result set is 1.
pre A result set must be open and the cursor must be able to perform absolute moves. The Num parameter must contain a positive integer.
post If the cursor was successfully moved to a specific record then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output.

relative(Num, Output)

func Move the cursor a number of rows up or down from the current position of the current row in the result set. Default cursors cannot be moved by this method, to make a cursor do this see putScrollable/2.
pre A result set must be open and the cursor must be able to perform relative moves. The Num parameter must contain a positive integer.
post If the cursor was successfully moved to a record then true was assigned to Output, if there was an error moving the cursor then false was assigned to Output.

putDateFormatString(Str)

func Put the default date format string for date fields. All new query instances allocated after this method was called will have the same date format string.
pre The variable Str must contain a string.
post The value of the parameter Str was stored as the date format string.
arrow.gif (1632 bytes) for more information about format strings see date and time formatting.

putTimeFormatString(Str)

func Put the default time format string for time fields. All new query instances allocated after this method was called will have the same time format string.
pre The variable Str must contain a string.
post The value of the parameter Str was stored as the time format string.
arrow.gif (1632 bytes) for more information about format strings see date and time formatting.

putLongFieldReadMode( LFReadMode )

func Determine how long fields are read. The three allowed values of the LFReadMode parameter are; read_ignore , read_limited, and read_complete.
pre The LFReadMode parameter must have one of the following values: read_ignore , read_limited, and read_complete.
post The value of the parameter LFReadMode was stored.
arrow.gif (1632 bytes) see also: long fields. If a query is associated with a database then it copies the readmode attribute of the database instance.

longFieldReadMode( LFReadMode )

func Return the value of the parameter that determines how long fields are read.
pre TRUE
post The value of the parameter LFReadMode was unified with the read mode.
arrow.gif (1632 bytes) see also: long fields

putLongFieldReadLimit( NumBytes )

func Determine how many bytes are read if long fields are not completely read.
pre The NumBytes parameter must contains a positive integer value.
post The value of the parameter NumBytes was stored.
arrow.gif (1632 bytes) see also: long fields. If a query is associated with a database then it copies the number-of-bytes attribute of the database instance.

longFieldReadLimit( OutputBytes )

func Return the number of bytes that is read if only parts of long fields are read.
pre TRUE
post The number of bytes that is read was unified with the OutputBytes parameter.
arrow.gif (1632 bytes) see also: long fields

putScrollable(YesNo, Output)

func Make the cursor a forward-only cursor or a cursor that can be moved in any direction inside a result set. Default cursors are forward-only because they are the fastest and require less memory. To make a cursor scroll in any direction the value of the parameter YesNo must be true, if a cursor must become a forward-only cursor the value of the parameter YesNo must be false.
Changing the scrolling capabilities of a cursor can only be done if NO result set is open.
pre A result set must NOT be open. The YesNo parameter must contain a boolean value.
post If the property was successfully changed then true was assigned to Output, if there was an error then false was assigned to Output.

forwardOnly(Output)

func Determine if the cursor is a forward-only cursor or can be scrolled in any direction.
pre TRUE
post If the cursor is a forward-only cursor then true was assigned to Output, else if the cursor can be scrolled in any direction false was assigned to output.

prepare(SQL, Output, ErrorCode)

func Prepare the SQL statement, the statement may contain parameters. The SQL statement is compiled and stored by the database engine, it is not executed. To assign values to input parameters of a prepared SQL statement see putParameter/3. To execute a prepared SQL statement call the method execute/2.
pre The variable SQL must contain a string.
post If there was no error preparing the SQL statement then true was assigned to Output, if there was an error then false was assigned to Output and a more specific error code value was assigned to the variable ErrorCode. To translate the error code to an error message use the predicate dberror/2.

execute(Output, ErrorCode)

func Execute a prepared SQL statement. All the input parameters of the prepared SQL statement, if it has any,  must have been assigned a value by the method putParameter/3.
pre A statement must have been prepared and all the input parameters must have been assigned a value.
post If there was no error executing a prepared SQL statement then true was assigned to Output, if there was an error then false was assigned to Output and a more specific error code value was assigned to the variable ErrorCode. To translate the error code to an error message use the predicate dberror/2.
If the SQL statement was successful and it was a SELECT statement a result set can be returned.

putParameter(ParIndex, Value, Output)

func Assign a value to a parameter of a prepared SQL statement. The index of the first parameter is 0.
pre The variable ParIndex must contain an integer and the variable Value must not be empty.
post If there was no error assigning the value to the parameter then true was assigned to Output, if there was an error then false was assigned to Output.

parameter(ParIndex, OutValue, Output)

func Retrieve the current value of a parameter. The index of the first parameter is 0.
pre The variable ParIndex must contain an integer.
post If there was no error getting the current value of the parameter then true was assigned to Output, if there was an error then false was assigned to Output.

numParameters(Output)

func Retrieve the number of parameters of a prepared SQL statement. The index of the first parameter is 0.
pre A statement must have been prepared.
post The number of parameters in a prepared SQL statement was assigned to Output.

parameterInfo(Pos, DataType, Size, Decimals, Nullable, Output)

func Retrieve information about a parameter of a prepared SQL statement. The index of the first parameter is 0. The information returned about the parameter is: the data type (DataType), the size in bytes of the data for the parameter (Size), the number of decimals for a floating point value (Decimals) and if the value of the parameter may be NULL (Nullable).
pre A statement must have been prepared.
post If there was a parameter at the same position as the value of variable Pos then information about the parameter was assigned to the variables DataType, Size, Decimals and Nullable. If the information was successfully retrieved then was true assigned to Output, if there was an error then was false assigned to Output.

isParameterLongField(Pos, Output)

func Determine if the parameter of a prepared SQL statement is connected to a long field. The index of the first parameter is 0.
pre A statement must have been prepared.
post If the parameter is connected to a long field then true was assigned to Output, else was false assigned.

putParameterLongFieldSize(Pos, NumBytes)

func Set the number of bytes that will be written to the parameter that is connected to a long field. The index of the first parameter is 0.
pre A statement must have been prepared and NumBytes must be an integer specifying the exact number of bytes that will be written to the long field.
post If the parameter is connected to a long field then true was assigned to Output, else was false assigned.

isFunction(SQL, Output)

func Determine if a database procedure is defined as a function or as a procedure.
pre The SQL variable must contain the name of a database procedure.
post If the database procedure was defined as a function then was true assigned to Output, else was false assigned to Output.

prepareProcedure(SQL, ProcName, Output, ErrorCode)

func Have a call to a database stored procedure prepared, the procedure call may contain parameters. The variable SQL must contain the call to the procedure and the variable ProcName must just contain the name of the database stored procedure. For instance; if the SQL variable contains '{call CustOrderHist( ? )}' then the ProcName variable must contain the string 'CustOrderHist'.
To execute a prepared procedure call the method execute/2.
pre The SQL and ProcName variables must not be empty.
post If the database procedure was correctly prepared then was true assigned to Output, else was false assigned to Output and a more specific error code was assigned to ErrorCode.
arrow.gif (1632 bytes) Each time this method is called the procedure parameters are bound to internal data buffers, to prevent this you can use the methods bindProcedureParameters/2 and execute/3.
See also: procedures

bindProcedureParameters( ProcName, Output )

func Bind to the parameters of a stored database procedure, the name of the stored procedure must be the value of the ProcName parameter. It is possible to execute a stored procedure with a call to execute/3 after the parameters were bound. The first argument to execute/3 would be a call to the stored procedure, for instance:  '{call CustOrderHist( ? )}'
pre The ProcName variable must not be empty.
post If the procedure parameters were correctly bound was true unified with Output, else was false unified with Output.

queryTables(Normal, System, Views, Output)

func Create a result set containing table information of the database. If Normal is true the normal tables of the database are included, else not. If System is true the system tables of the database are included, else not. If the parameter Views is true the views of the database are included, else not. The created result set has 5 columns:
Column name DataType Comments
TABLE_CAT Varchar catalog name, empty if catalogs not applicable for database
TABLE_SCHEM Varchar schema name, empty if database does not support schemas
TABLE_NAME Varchar table name
TABLE_TYPE Varchar string describing table type
REMARKS Varchar a description of the table
pre TRUE
post If Output was assigned true a result set was created containing information about the tables in the database. If there was an error creating the result set then was false assigned to Output.

queryTablePrivileges(TableName, Output)

func Create a result set describing the privileges of a table in the database. The value of the TableName parameter is used for searching the database catalog. The created result set has 7 columns:
Column name DataType Comments
TABLE_CAT Varchar catalog name, empty if catalogs not applicable for database
TABLE_SCHEM Varchar schema name, empty if database does not support schemas
TABLE_NAME Varchar not NULL table name
GRANTOR Varchar name of the user who granted the privilege
GRANTEE Varchar not NULL name of user to whom privilege was granted
PRIVILEGE Varchar not NULL the table privilege
IS_GRANTABLE Varchar indicates whether the grantee is permitted to grant the privilege to other users
pre TRUE
post If Output was assigned true a result set was created containing information about the table privileges of the table in the database. If there was an error creating the result set then was false assigned to Output.

queryColumns(TableName, Output)

func Create a result set containing column information of a table. The value of the TableName parameter is used for searching the database catalog. The created result set has 18 columns
Column name DataType Comments
TABLE_CAT Varchar catalog name, empty if catalogs not applicable for database
TABLE_SCHEM Varchar schema name, empty if database does not support schemas
TABLE_NAME Varchar not NULL table name
COLUMN_NAME Varchar not NULL name of column
DATA_TYPE Smallint SQL data type
TYPE_NAME Varchar not NULL data source dependant data type name
COLUMN_SIZE Integer the number of bytes allocated by database to store data
BUFFER_LENGTH Integer number of bytes transferred if values are copied to ODBC, for numeric datatypes the necessary buffer may be different than the size of the column
DECIMAL_DIGITS Smallint total number of digits to the right of decimal point
NUM_PREC_RADIX Smallint if it is 10 the values in the COLUMN_SIZE and DECIMAL_DIGITS give the number of decimal digits allowed for the column, if it is 2 the values in COLUMNS_SIZE and DECIMAL_DIGITS give the number of bits allowed in the column
NULLABLE Smallint not NULL indicates if a column can accept NULLs or not or if it is unknown, 0 = no nulls, 1 = nullable
REMARKS Varchar a description of the column
COLUMN_DEF Varchar a default value of the column
SQL_DATA_TYPE Smallint not NULL SQL data type, this column returns the non-concise data type for datetime and interval data types
SQL_DATETIME_SUB Smallint the subtype code for datetime and interval data types
CHAR_OCTET_LENGTH Integer maximum length in bytes of a character or binary data type column
ORDINAL_POSITION Integer not NULL ordinal position of column in the table
IS_NULLABLE Varchar "NO" if the column does not include NULLs, "YES" if the column could include columns, a zero-length string if nullability is unknown
pre TRUE
post If Output was assigned true a result set was created containing information about the columns in the table. If there was an error creating the result set then was false assigned to Output.

queryColumnPrivileges(TableName, ColumnName, Output)

func Create a result set describing the privileges of the columns in a table. The value of the TableName parameter is used for searching the database catalog. The created result set has 7 columns:
Column name DataType Comments
TABLE_CAT Varchar catalog name, empty if catalogs not applicable for database
TABLE_SCHEM Varchar schema name, empty if database does not support schemas
TABLE_NAME Varchar not NULL table name
COLUMN_NAME Varchar not NULL name of column
GRANTOR Varchar name of the user who granted the privilege
GRANTEE Varchar not NULL name of user to whom privilege was granted
PRIVILEGE Varchar not NULL the table privilege
IS_GRANTABLE Varchar indicates whether the grantee is permitted to grant the privilege to other users
pre TRUE
post If Output was assigned true a result set was created containing information about the column privileges of the table in the database. If there was an error creating the result set then was false assigned to Output.

queryPrimaryKeys(TableName, Output)

func Create a result set describing the columns that make up the primary key of a table. The value of the TableName parameter is used for searching the database catalog. The created result set has 7 columns:
Column name DataType Comments
TABLE_CAT Varchar catalog name, empty if catalogs not applicable for database
TABLE_SCHEM Varchar schema name, empty if database does not support schemas
TABLE_NAME Varchar not NULL table name
COLUMN_NAME Varchar not NULL name of column
KEY_SEQ Smallint not NULL column sequence number in key, starting with 1
PK_NAME Varchar primary key name
pre TRUE
post If Output was assigned true a result set was created containing information about the columns that make up a primary key of the table in the database. If there was an error creating the result set then was false assigned to Output.

queryForeignKeys(TableName, Output)

func Create a result set containing all of the foreign keys in the specified table that point to primary keys in other tables. The value of the TableName parameter is used for searching the database catalog. The created result set has 14 columns:
Column name DataType Comments
PKTABLE_CAT Varchar primary key catalog name
PKTABLE_SCHEM Varchar primary key schema name
PKTABLE_NAME Varchar not NULL primary key table name
PKCOLUMN_NAME Varchar not NULL primary key name of column
FKTABLE_CAT Varchar foreign key catalog name
FKTABLE_SCHEM Varchar foreign key schema name
FKTABLE_NAME Varchar not NULL foreign key table name
FKCOLUMN_NAME Varchar not NULL foreign key name of column
KEY_SEQ Smallint not NULL column sequence number, starting with 1
UPDATE_RULE Smallint action to be applied to the foreign key when the SQL operation is UPDATE. 0 = cascaded, 1 = restrict, 2= set null, 3 = no action, 4 = set default
DELETE_RULE Smallint action to be applied to the foreign key when the SQL operation is DELETE. 0 = cascaded, 1 = restrict, 2= set null, 3 = no action, 4 = set default
FK_NAME Varchar foreign key name
PK_NAME Varchar primary key name
DEFERRABILITY Smallint 5 = initially deferred, 6 = initially immediate, 7 = not deferrable
pre TRUE
post If Output was assigned true a result set was created containing information about the columns that make up foreign keys of the table in the database. If there was an error creating the result set then was false assigned to Output.

queryProcedures(Output)

func Create a result set containing information of all the procedures (executable entities) in the database. The created result set has 5 columns:
Column name DataType Comments
PROCEDURE_CAT Varchar catalog name, empty if catalogs not applicable for database
PROCEDURE_SCHEM Varchar schema name, empty if database does not support schemas
PROCEDURE_NAME Varchar procedure name
NUM_INPUT_PARAMS n/a reserved for future use, applications should not rely on the data returned
NUM_OUTPUT_PARAMS n/a reserved for future use
NUM_RESULT_SETS n/a reserved for future use
REMARKS Varchar a description of the procedure
PROCEDURE_TYPE Smallint defines procedure type: 0 = unknown, 1 = procedure, 2 = function, the procedure has a return value
pre TRUE
post If Output was assigned true a result set was created containing information about the procedures in the database. If there was an error creating the result set then was false assigned to Output.

queryProcedureColumns(ProcedureName, Output)

func Create a result set containing information about the input and output parameters of the procedure identified by the value of the ProcedureName parameter. The created result set has 19 columns:
Column name DataType Comments
PROCEDURE_CAT Varchar catalog name
PROCEDURE_SCHEM Varchar schema name
PROCEDURE_NAME Varchar not NULL table name
COLUMN_NAME Varchar not NULL name of column
COLUMN_TYPE Smallint not NULL 0 = unknown, 1 = input parameter, 2 = input-output parameter, 3 = result set column, 4 = output parameter, 5 = return value
DATA_TYPE Smallint not NULL SQL data type
TYPE_NAME Varchar not NULL data source dependant data type name
COLUMN_SIZE Integer the number of bytes allocated by database to store data
BUFFER_LENGTH Integer number of bytes transferred if values are copied to ODBC, for numeric data types the necessary buffer may be different than the size of the column
DECIMAL_DIGITS Smallint total number of digits to the right of decimal point
NUM_PREC_RADIX Smallint if it is 10 the values in the COLUMN_SIZE and DECIMAL_DIGITS give the number of decimal digits allowed for the column, if it is 2 the values in COLUMNS_SIZE and DECIMAL_DIGITS give the number of bits allowed in the column
NULLABLE Smallint not NULL indicates if a column can accept NULLs or not or if it is unknown, 0 = no nulls, 1 = nullable
REMARKS Varchar a description of the column
COLUMN_DEF Varchar a default value of the column
SQL_DATA_TYPE Smallint not NULL SQL data type, this column returns the non-concise data type for datetime and interval data types
SQL_DATETIME_SUB Smallint the subtype code for datetime and interval data types
CHAR_OCTET_LENGTH Integer maximum length in bytes of a character or binary data type column
ORDINAL_POSITION Integer not NULL ordinal position of column in the table, a return value has a position value of 0
IS_NULLABLE Varchar "NO" if the column does not include NULLs, "YES" if the column could include columns, a zero-length string if nullability is unknown
pre TRUE
post If Output was assigned true a result set was created containing information about the procedure columns. If there was an error creating the result set then was false assigned to Output.

queryDataTypes(Output)

func Create a result set containing information about the data types supported by the database. The data types are intended for use in Data Definition Language (DDL) statements. The created result set has 19 columns:
Column name DataType Comments
TYPE_NAME Varchar not NULL data source dependant data type name
DATA_TYPE Varchar SQL data type
COLUMN_SIZE Integer the number of bytes allocated by database to store data
LITERAL_PREFIX Varchar character(s) used to prefix a literal, for example a single quotation mark for character data types or 0x for binary data types
LITERAL_SUFFIX Varchar character(s) used to terminate a literal, for example a single quotation mark for character data types
CREATE_PARAMS Varchar a list of keywords corresponding to each parameter that may be specified in parenthesis when using the name in the TYPE_NAME field, for example: for DECIMAL the CREATE_PARAMS could be 'precision, scale', for VARCHAR it could be 'length'
NULLABLE Smallint not NULL indicates if a column can accept NULLs or not or if it is unknown, 0 = no nulls, 1 = nullable
CASE_SENSITIVE Smallint not NULL 0 = case insensitive, 1 = case sensitive
SEARCHABLE Smallint not NULL how the data type is used in a where clause, 0 =cannot be used, 1 = can be used but only with the LIKE predicate, 2 = can be used with all comparison operators except the LIKE predicate, 3 = can be used with all comparison predicates
UNSIGNED_ATTRIBUTE Smallint 0 = data type is unsigned, 1 = data type is signed
FIXED_PREC_SCALE Smallint not NULL whether data type has predefined fixed precision and scale, 0 = no fixed precision or scale, 1 = fixed precision and scale
AUTO_UNIQUE_VALUE Smallint 0 = data type is not autoincrementing, 1 = data type is autoincrementing
LOCAL_TYPE_NAME Varchar localized version of the data source dependent name of the data type
MINIMUM_SCALE Smallint minimum scale of the data type on the database
MAXIMUM_SCALE Smallint maximum scale of the data type on the database
SQL_DATA_TYPE Smallint not NULL value of the SQL data type as it appears in the SQL_DESC_TYPE field
SQL_DATETIME_SUB Smallint for data types it contains the datetime/interval subcode
NUM_PREC_RADIX Integer if this column contains 2 the COLUMN_SIZE specifies a number of bits, if this column contains 10 the COLUMN_SIZE specifies a number of decimal digits
INTERVAL_PRECISION Smallint if data type is an interval data type this column the value of interval leading precision
pre TRUE
post If Output was assigned true a result set was created containing information about the data types. If there was an error creating the result set then was false assigned to Output.

callbacks

onMoreData(Sender, ParameterIndex, Type, Value)

func This callback is executed when a value is written to a long field, the DBMS asks for the data to write. The second parameter is the index of the parameter in the SQL command (the index of the first parameter is 0. The 'Type' parameter indicates the type of long field, it is either 'text' or 'binary'. The last parameter is an empty variable to which a value can be assigned, that value will be written to the long field.
pre The variable Sender refers to the query instance executing the SQL statement. The ParameterIndex contains an integer and the parameter Type contains the atom 'text' or 'binary'.
post The value assigned to the last parameter will be written to the DBMS if a solution was found for the goal executing the callback. If the field is a binary field then the data must have been base64 encoded, see atom_base64/2.