Contents Up Previous Next

Recordset

Database classes overview

Each recordset represents an ODBC database query. You can make multiple queries at a time by using multiple recordsets with a database or you can make your queries in sequential order using the same recordset.

recordset-create
recordset-delete
recordset-execute-sql
recordset-get-char-data
recordset-get-col-name
recordset-get-col-type
recordset-get-columns
recordset-get-database
recordset-get-data-sources
recordset-get-error-code
recordset-get-filter
recordset-get-float-data
recordset-get-foreign-keys
recordset-get-int-data
recordset-get-number-cols
recordset-get-number-fields
recordset-get-number-params
recordset-get-number-records
recordset-get-primary-keys
recordset-get-result-set
recordset-get-table-name
recordset-get-tables
recordset-goto
recordset-is-bof
recordset-is-field-dirty
recordset-is-field-null
recordset-is-col-nullable
recordset-is-eof
recordset-is-open
recordset-move
recordset-move-first
recordset-move-last
recordset-move-next
recordset-move-prev
recordset-query
recordset-set-table-name


recordset-create

long ( recordset-create long db optional string type = "wxOPEN_TYPE_DYNASET" optional string options = "wxOPTION_DEFAULT")

Constructs a recordset object and returns its id. db is a pointer to the database instance you wish to use the recordset with. Currently there are two possible values of type:

The options parameter is not used yet.

The function appends the recordset object to the parent database's list of recordset objects, for later destruction when the database is destroyed.


recordset-delete

long ( recordset-delete long id)

Deletes the recordset. All data except that stored in user-defined variables will be lost. It also unlinks the recordset object from the parent database's list of recordset objects.


recordset-execute-sql

long ( recordset-execute-sql long id string sql)

Directly executes a SQL statement. The data will be presented as a normal result set. Note that the recordset must have been created as a snapshot, not dynaset. Dynasets will be implemented in the near future.

Examples of common SQL statements are given in A selection of SQL commands.


recordset-get-char-data

string ( recordset-get-char-data long id string-or-long col)

Returns the character (string) data for the current record at the specified column. The column can be a name or an integer position (starting from zero).


recordset-get-col-name

string ( recordset-get-col-name long id long col)

Gets the name of the coumn at position col. Returns the empty string if col does not exist.


recordset-get-col-type

string ( recordset-get-col-type long id string-or-long col)

Gets the name of the coumn at position col or name col. Returns "SQL_TYPE_NULL" if col does not exist.

See ODBC SQL data types for the possible return values from this function.


recordset-get-columns

long ( recordset-get-columns long id optional string table = "")

Returns the columns of the table with the specified name. If no name is given, the internal class member table will be used. If both names are NULL nothing will happen. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) COLUMN_NAME
4 (SMALLINT) DATA_TYPE
5 (VARCHAR) TYPE_NAME
6 (INTEGER) PRECISION
7 (INTEGER) LENGTH
8 (SMALLINT) SCALE
9 (SMALLINT) RADIX
10 (SMALLINT) NULLABLE
11 (VARCHAR) REMARKS


recordset-get-database

long ( recordset-get-database long id)

Returns the identifier of the parent database.


recordset-get-data-sources

long ( recordset-get-data-sources long id)

Gets the currently-defined data sources via the ODBC manager. The data will be presented as a normal result set. See the documentation for the ODBC function SQLDataSources for how the data is organized. The name of the source is at column 0.


recordset-get-error-code

string ( recordset-get-error-code long id)

Returns the error code of the last ODBC action. This will be a string containing one of:

SQL_ERROR General error.
SQL_INVALID_HANDLE An invalid handle was passed to an ODBC function.
SQL_NEED_DATA ODBC expected some data.
SQL_NO_DATA_FOUND No data was found by this ODBC call.
SQL_SUCCESS The call was successful.
SQL_SUCCESS_WITH_INFO The call was successful, but further information can be obtained from the ODBC manager.


recordset-get-filter

string ( recordset-get-filter long id)

Returns the current filter.


recordset-get-float-data

double ( recordset-get-float-data long id string-or-long col)

Returns the floating-point data for the current record at the specified column. The column can be a name or an integer position (starting from zero).


recordset-get-foreign-keys

long ( recordset-get-foreign-keys long id optional string ftable = "" optional string ktable = "")

Returns a list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables), or a list of foreign keys in other tables that refer to the primary key in the specified table.

If ptable contains a table name, this function returns a result set containing the primary key of the specified table.

If ftable contains a table name, this functions returns a result set of containing all of the foreign keys in the specified table and the primary keys (in other tables) to which they refer.

If both ptable and ftable contain table names, this function returns the foreign keys in the table specified in ftable that refer to the primary key of the table specified in ptable. This should be one key at most.

GetForeignKeys returns results as a standard result set. If the foreign keys associated with a primary key are requested, the result set is ordered by FKTABLE_QUALIFIER, FKTABLE_OWNER, FKTABLE_NAME, and KEY_SEQ. If the primary keys associated with a foreign key are requested, the result set is ordered by PKTABLE_QUALIFIER, PKTABLE_OWNER, PKTABLE_NAME, and KEY_SEQ. The following table lists the columns in the result set.

0 (VARCHAR) PKTABLE_QUALIFIER
1 (VARCHAR) PKTABLE_OWNER
2 (VARCHAR) PKTABLE_NAME
3 (VARCHAR) PKCOLUMN_NAME
4 (VARCHAR) FKTABLE_QUALIFIER
5 (VARCHAR) FKTABLE_OWNER
6 (VARCHAR) FKTABLE_NAME
7 (VARCHAR) FKCOLUMN_NAME
8 (SMALLINT) KEY_SEQ
9 (SMALLINT) UPDATE_RULE
10 (SMALLINT) DELETE_RULE
11 (VARCHAR) FK_NAME
12 (VARCHAR) PK_NAME


recordset-get-int-data

long ( recordset-get-int-data long id string-or-long col)

Returns the integer data for the current record at the specified column. The column can be a name or an integer position (starting from zero).


recordset-get-number-cols

long ( recordset-get-number-cols long id)

Returns the number of columns in the result set.


recordset-get-number-fields

long ( recordset-get-number-fields long id)

Not implemented.


recordset-get-number-params

long ( recordset-get-number-params long id)

Not implemented.


recordset-get-number-records

long ( recordset-get-number-records long id)

Returns the number of records in the result set.


recordset-get-primary-keys

long ( recordset-get-primary-keys long id optional string table = "")

Returns the column names that comprise the primary key of the table with the specified name. If no name is given the class member tablename will be used. If both names are NULL nothing will happen. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) COLUMN_NAME
4 (SMALLINT) KEY_SEQ
5 (VARCHAR) PK_NAME


recordset-get-result-set

long ( recordset-get-result-set long id)

Copies the data presented by ODBC into the recordset. Depending on the recordset type all or only one record(s) will be copied. Usually this function will be called automatically after each successful database operation.


recordset-get-table-name

string ( recordset-get-table-name long id)

Returns the name of the current table.


recordset-get-tables

long ( recordset-get-tables long id)

Gets the tables of a database. The data will be presented as a normal result set, organized as follows:

0 (VARCHAR) TABLE_QUALIFIER
1 (VARCHAR) TABLE_OWNER
2 (VARCHAR) TABLE_NAME
3 (VARCHAR) TABLE_TYPE (TABLE, VIEW, SYSTEM TABLE, GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM, or database-specific type)
4 (VARCHAR) REMARKS


recordset-goto

long ( recordset-goto long id long n)

Moves the cursor to the record with the number n, where the first record has the number 0.


recordset-is-bof

long ( recordset-is-bof long id)

Returns 1 if the user tried to move the cursor before the first record in the set.


recordset-is-field-dirty

long ( recordset-is-field-dirty long id string-or-long field)

Returns 1 if the given field has been changed but not saved yet.


recordset-is-field-null

long ( recordset-is-field-null long id string-or-long field)

Returns 1 if the given field has no data.


recordset-is-col-nullable

long ( recordset-is-col-nullable long id string-or-long field)

Returns 1 if the given column may contain no data.


recordset-is-eof

long ( recordset-is-eof long id)

Returns 1 if the user tried to move the cursor behind the last record in the set.


recordset-is-open

long ( recordset-is-open long id)

Returns 1 if the parent database is open.


recordset-move

long ( recordset-move long id long rows)

Moves the cursor a given number of rows. Negative values are allowed.


recordset-move-first

long ( recordset-move-first long id)

Moves the cursor to the first record.


recordset-move-last

long ( recordset-move-last long id)

Moves the cursor to the last record.


recordset-move-next

long ( recordset-move-next long id)

Moves the cursor to the next record.


recordset-move-prev

long ( recordset-move-prev long id)

Moves the cursor to the previous record.


recordset-query

long ( recordset-query long id string columns string table optional string filter)

Start a query. An SQL string of the following type will automatically be generated and executed: "SELECT columns FROM table WHERE filter".


recordset-set-table-name

long ( recordset-set-table-name long id string table)

Specify the name of the table you want to use.