SQLite Cursor


A SQLite database cursor is a object (control structure) that lets you traverse records in a database. Cursors facilitate subsequent processing in conjunction with the traversal, such as retrieval, addition and removal of database records.

A variable becomes a cursor object by using the SqlCursor(), SqlQuery() or SqlQueryRaw() functions. Cursors are used to process individual rows returned by SQLite queries. Cursors enable manipulation of whole result-sets at once. In this scenario, a cursor enables the rows in a result-set to be processed sequentially.


SqlCursor()


SqlCloseCursor


SqlQuery()


SqlQueryRaw()



Cursor Functions

Function Returns
SqlGetColCount(cursor) = Returns the number of columns currently selected by the (cursor).
SqlGetColIndex(cursor,name$) = Returns the index of column (name$) within the current (cursor).
SqlGetColName$(cursor,index) = Returns the name of the column at the given (index).
SqlGetColNames$(cursor) = s$() - Returns a string array containing all the column names within the current (cursor).
SqlGetRecCount(cursor) = Returns the number of records selected by the current (cursor).
isSqlCursorClosed(cursor) = Returns 1 if the (cursor) is closed, 0 if it is open.



Data Reading Functions.

Function Returns
SqlGetDouble(cursor,index) = Reads a double field from the (cursor) in column (index).
SqlGetFloat(cursor,index) = Reads a float field from the (cursor) in column (index).
SqlGetInt(cursor,index) = Reads a integer field from the (cursor) in column (index).
SqlGetLong(cursor,index) = Reads a long integer field from the (cursor) in column (index).
SqlGetShort(cursor,index) = Reads a short integer field from the (cursor) in column (index).
SqlGetString$(cursor,index) = Reads a text string field from the (cursor) in column (index).
SqlGetI$(cursor{,delimiter$}) = Reads all the columns from the row the cursor is currently on. The rows are returned as a delimited string. If not specified the delimiter character defaults to a comma.
SqlGetA$(cursor) = s$() - Reads all the columns from the row the cursor is currently on. The column values are returned as a one dimensional string array.
SqlGetAll$(cursor) = s$() - Reads all the columns and all the rows currently selected by the cursor. The data is returned in a two dimensional string array ordered as s$(row,col).
isSqlColNull(cursor,index) = Returns 1 if column (index) is null, 0 if not null.



Cursor Positioning Functions.

Function Returns
isSqlBeforeFirst(cursor) = Returns 1 if (cursor) is positioned before the first record, 0 if not.
isSqlAfterLast(cursor) = Returns 1 if (cursor) is positioned after the last record, 0 if not.
isSqlFirst(cursor) = Returns 1 if (cursor) is positioned on the first record, 0 if not.
isSqlLast(cursor) = Returns 1 if (cursor) is positioned on the last record, 0 if not.
SqlFirst(cursor) = Moves the cursor to the first record. Returns 1 if successful, 0 if not.
SqlNext(cursor) = Moves the cursor to the next record. Returns 1 if successful, 0 if not.
SqlPrev(cursor) = Moves the cursor to the previous record. Returns 1 if successful, 0 if not.
SqlLast(cursor) = Moves the cursor to the last record. Returns 1 if successful, 0 if not.
SqlMove(cursor,offset) = Moves the cursor forward if (offset) is positive, backward if negative. Returns 1 if successful, 0 if not.
SqlPos(cursor,row) = Moves the cursor to the specified record (row). Returns 1 if successful, 0 if not.


SQLite






Become a Patron