Statement class

The Statement class provides a context to execute a series of SQL statements on a data source and retrieve the results. A statement is always associated with a particular data source. By constructing multiple statements on the same data source, you can access the results of multiple queries at the same time.

Constructing

Statement( data-source : DataSource ) : Statement

Constructs a statement associated with the specified data source. The data source must be connected; if not the resulting Statement instance is invalid.

Getting state information

isOK( ) : Boolean

Returns true if the previous operation returned "SQL_SUCCESS" or SQL_SUCCESS_WITH_INFO"; false otherwise.

isSuccess( ) : Boolean

Returns true if the previous operation returned "SQL_SUCCESS"; false otherwise.

isSuccessWithInfo( ) : Boolean

Returns true if the previous operation returned "SQL_SUCCESS_WITH_INFO"; false otherwise.

getCode( ) : Number

Returns the native (system- or driver-specific) ODBC error or information code generated by the previous operation, or zero if there was no such code.

getMessage( ) : String

Returns the human-readable ODBC error or information message generated by the previous operation, or the empty string if there was no such message.

The message is formatted to already include the SQL state and the native code.

isValid( ) : Boolean

Returns true if the associated data source is connected, false otherwise.

Executing SQL statements

execute( sql : String ) : Boolean

Executes the specified SQL statement on the associated data source, and stores the results.

Returns the value of isOK() after performing the operation.

tables ( table-type : String ) : String

Returns a list of table names. The list includes all tables of the specified type in the data source. The table type must be specified in all upper-case, and multiple types must be comma-separated (for example: "TABLE, VIEW"). If the argument is missing, null or empty, information is retrieved about all tables in the data source.

Some databases support the "SHOW TABLES" query to retrieve more details about tables as a regular result set. After passing this query to the database with the execute() function, the result set contains a column with the table names and further columns with addiitonal information on each table.

columns ( table-name : String ) : String

Returns a list of column names, including all columns in the specified table.

Some databases support the "SHOW COLUMNS FROM <table-name>" query to retrieve more details about columns in a table as a regular result set. After passing this query to the database with the execute() function, the result set contains a column with the column names and further columns with addiitonal information on each column.

Contents