Function Reference


_SQLite_QueryFinalize

Finalizes an _SQLite_Query() based query. The query is interrupted

#include <SQLite.au3>
_SQLite_QueryFinalize ( $hQuery )

Parameters

$hQuery Query handle generated by _SQLite_Query()

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_finalize'
2 - Call prevented by SafeMode

Remarks

The _SQLite_QueryFinalize() function is called to delete a prepared SQL statement obtained by a previous call to _SQLite_Query(). If the statement was executed successfully, or not executed at all, then $SQLITE_OK is returned. If execution of the statement failed then an error code is returned.

All prepared statements must be finalized before _SQLite_Close() is called or else the call will fail with a return code of $SQLITE_BUSY.

Related

_SQLite_Query, _SQLite_QueryReset

Example

#include <MsgBoxConstants.au3>
#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) ; Read out the Tablenames
MsgBox($MB_SYSTEMMODAL, "SQLite", "Row ID is : " & StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ; This get 1 row at a time
        MsgBox($MB_SYSTEMMODAL, "SQLite", "Get Data using FetchData : " & StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
        _SQLite_QueryFinalize($hQuery) ; This will stop the query, getting more rows
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello