SQLiteRecordSet


super: RecordSet

This class is reserved and cannot be directly instantiated.

A RecordSet is a data structure that consists of a group of database records, and can either come from a base table or as the result of a query to the table. At any time, the RecordSet object refers to only a single record within the set as the current record, use the MoveTo method to change current record position. Rows and columns are 0-based indexed.

Events

  • DidStart() Event raised when DataSet started retrieving data.

  • NewValue(value: Object) Event raised when a new value becomes available.

  • DidFinish() Event raised when DataSet finished retrieving data.

  • DidFail() Event raised in case of DataSet error.

Properties

  • var sql: String Use to this property to retrieve or set current sql statement.

  • var hasRow: Bool Check if RecordSet has a row ready to be read. (read-only)

  • var rowCount: Int Number of rows in the RecordSet. (read-only)

  • var columnCount: Int Number of columns in the RecordSet. (read-only)

Methods

  • func run() Perform the query specified in the current RecordSet (specified by the sql property). Each control which uses this RecordSet for it dataSet property is notified when new rows are available and when the run is completed, and updates itself to show the new data. This method automatically connects the parent Database instance if needed.

  • func columnType(index: Int): DatabaseFieldType Returns column type specified by the index parameter.

  • func columnName(index: Int): String Returns column name specified by the index parameter.

  • func stringValue(index: Int): String Returns column value converted to String specified by the index parameter.

  • func intValue(index: Int): Int Returns column value converted to Int32 specified by the index parameter.

  • func int64Value(index: Int): Int Returns column value converted to Int64 specified by the index parameter.

  • func floatValue(index: Int): Float Returns column value converted to Float specified by the index parameter.

  • func doubleValue(index: Int): Float Returns column value converted to Double specified by the index parameter.

  • func boolValue(index: Int): Bool Returns column value converted to Boolean specified by the index parameter.

  • func blobValue(index: Int): Data Returns column value (not converted) specified by the index parameter.

  • func isCached(): Bool Check if RecordSet is actually in cache (and moveTo method can be used).

  • func moveTo(index: Int): Bool Move current record pointer specified by the index parameter. Returns true is operation succedd.

  • func moveNext(): Bool Move to the next record. Returns false is no more records are availables.

  • func moveFirst(): Bool Move to the first record.

  • func moveLast(): Bool Move to the latest record.

  • func movePrevious(): Bool Move to the previous record. Returns false is no more records are availables.

Enumeration

DatabaseFieldType

  • .Blob
  • .DateTime
  • .Decimal
  • .Double
  • .Integer
  • .Null
  • .Text

Examples

Iterate through each record

while (rs.hasRow) {
    // access the values for the current row of the recordset
    // in this example we print the value of the column 'id' for the current row
    Console.write("ID: \(rs.id)")
    rs.moveNext();
}