Represent a collection of database records as required from DBIBaseTrans.query. You will not instantiate this class directly, instead, you must use DBIBaseTrans.query.
class DBIRecordset
asBlobID() | Get a field value as a blob ID string. |
asBoolean() | Get a field value as a Boolean. |
asDate() | Get a field value as a TimeStamp object with the date populated and the time zeroed. |
asDateTime() | Get a field value as a TimeStamp object. |
asInteger() | Get a field value as an Integer. |
asInteger64() | Get a field value as an Integer64. |
asNumeric() | Get a field value as a Numeric. |
asString() | Get a field value as a String. |
asTime() | Get a field value as a TimeStamp object with time populated and date zeroed. |
close() | Close a recordset |
fetchArray() | Get the next record as an Array. |
fetchDict() | Get the next record as a Dictionary. |
fetchObject() | Get the next record as an Object. |
getColumnCount() | Return the number of columns in the recordset. |
getColumnNames() | Get the column names as an array. |
getColumnTypes() | Get the column types as an array. |
getLastError() | Get the last error that occurred in this recordset from the database server. |
getRowCount() | Get the number of rows in the recordset. |
next() | Advanced the record pointer to the next record. |
Get a field value as a blob ID string.
DBIRecordset.asBlobID( idx, [bID] )
idx | field index |
bID | A pre-allocated string buffer that will be filled with blob ID. |
Returns: | A string value that can be used to retreive the content of a blob field. |
The value returned by this function can be then feed into blob related methods in the DBITransaction class, as the DBITransaction.readBlob method.
If the bID parameter is not provided, the function will create a new string and then return it; if it is provided, then the given string buffer will be filled with the blob ID data, and eventually returned on success.
Reusing the same item and filling it with new fetched values can be more efficient by several orders of magnitude.
Get a field value as a Boolean.
DBIRecordset.asBoolean( idx )
idx | field index |
Returns: | Boolean representation of database field contents or nil if field content is nil |
Get a field value as a TimeStamp object with the date populated and the time zeroed.
DBIRecordset.asDate( idx, [timestamp] )
idx | field index |
timestamp | A TimeStamp object that will be filled with the data in the field. |
Returns: | TimeStamp representation of database field contents or nil if field content is nil |
If the timestamp parameter is not provided, the function will create a new instance of the TimeStamp class and then return it; if it is provided, then that object will be filled and also returned on succesful completion.
Reusing the same object and filling it with new fetched values can be more efficient by several orders of magnitude.
Get a field value as a TimeStamp object.
DBIRecordset.asDateTime( idx, [timestamp] )
idx | field index |
timestamp | A TimeStamp object that will be filled with the data in the field. |
Returns: | TimeStamp representation of database field contents or nil if field content is nil |
If the timestamp parameter is not provided, the function will create a new instance of the TimeStamp class and then return it; if it is provided, then that object will be filled and also returned on succesful completion.
Reusing the same object and filling it with new fetched values can be more efficient by several orders of magnitude.
Get a field value as an Integer.
DBIRecordset.asInteger( idx )
idx | field index |
Returns: | Integer representation of database field contents or nil if field content is nil |
Get a field value as an Integer64.
DBIRecordset.asInteger64( idx )
idx | field index |
Returns: | Integer64 representation of database field contents or nil if field content is nil |
Get a field value as a Numeric.
DBIRecordset.asNumeric( idx )
idx | Field index. |
Returns: | Numeric representation of database field contents or nil if field content is nil |
Get a field value as a String.
DBIRecordset.asString( idx, [string] )
idx | field index |
string | A pre-allocated string buffer that will be filled with the content of the field. |
Returns: | String representation of database field contents or nil if field content is nil. |
If the string parameter is not provided, the function will create a new string and then return it; if it is provided, then the given string buffer will be filled with the contents of the field and also returned on succesful completion.
Reusing the same item and filling it with new fetched values can be more efficient by several orders of magnitude.
Get a field value as a TimeStamp object with time populated and date zeroed.
DBIRecordset.asTime( idx, [timestamp] )
idx | Field index. |
timestamp | A TimeStamp object that will be filled with the data in the field. |
Returns: | TimeStamp representation of database field contents or nil if field content is nil |
If the timestamp parameter is not provided, the function will create a new instance of the TimeStamp class and then return it; if it is provided, then that object will be filled and also returned on succesful completion.
Reusing the same object and filling it with new fetched values can be more efficient by several orders of magnitude.
Close a recordset
DBIRecordset.close( )
Get the next record as an Array.
DBIRecordset.fetchArray( )
Returns: | populated array or nil on EOF. |
Get the next record as a Dictionary.
DBIRecordset.fetchDict( )
Returns: | populated dictionary or nil on EOF. |
Get the next record as an Object.
DBIRecordset.fetchObject( obj )
obj | Object to populate with row data. |
Returns: | populated object or nil on EOF |
Please refer to the documentation of DBIRecord for more information on using the DBIRecord class.
Return the number of columns in the recordset.
DBIRecordset.getColumnCount( )
Returns: | Integer |
Get the column names as an array.
DBIRecordset.getColumnNames( )
Returns: | String array of column names |
Get the column types as an array.
DBIRecordset.getColumnTypes( )
Returns: | Integer array of column types |
Get the last error that occurred in this recordset from the database server.
DBIRecordset.getLastError( )
Returns: | String containing error message |
This error message is specific to the database server type currently in use.
Get the number of rows in the recordset.
DBIRecordset.getRowCount( )
Returns: | Integer |
Advanced the record pointer to the next record.
DBIRecordset.next( )
Returns: | true if successful, 0 if not successful, usually meaning the EOF has been hit. |
All new queries are positioned before the first record, meaning, next should be called before accessing any values.