Function Reference


_SQLite_FetchData

Fetches 1 row of data from a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_FetchData ( $hQuery, ByRef $aRow [, $bBinary = False [, $bDoNotFinalize = False [, $iColumns = 0]]] )

Parameters

$hQuery Queryhandle passed out by _SQLite_Query()
$aRow A 1 dimensional array containing a row of data
$bBinary [optional] Switch for binary mode ($aRow will be an array of binary strings)
$bDoNotFinalize [optional] Switch can be set to True if you need to keep the query unfinalized for further use.
(It is then the caller's responsability to invoke _SQLite_QueryFinalize() before closing database.)
$iColumns [optional] Number of columns to be returned ((Default = all)

Return Value

Success: $SQLITE_OK.
Failure: a value that can be compared against $SQLITE_* constants.
@error: -1 - SQLite reported an error (Check return value)
1 - Error calling SQLite API 'sqlite3_step'
2 - Error calling SQLite API 'sqlite3_data_count'
3 - Error calling SQLite API 'sqlite3_column_text16'
4 - Error calling SQLite API 'sqlite3_column_type'
5 - Error calling SQLite API 'sqlite3_column_bytes'
6 - Error calling SQLite API 'sqlite3_column_blob'
7 - Call prevented by SafeMode

Related

_SQLite_Query, _SQLite_QueryFinalize

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (A,B,C);")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQLite_Query(-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames($hQuery, $aNames)
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row
    ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
WEnd
_SQLite_QueryFinalize($hQuery)
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello
; 2           b           3
; 1           c           2           World