Function Reference


_SQLite_Exec

Executes a SQLite query, does not handle results

#include <SQLite.au3>
_SQLite_Exec ( $hDB, $sSQL [, $sCallBack = ""] )

Parameters

$hDB An open database, use -1 to use last opened database
$sSQL SQL statement to be executed
$sCallback [optional] if specified the function will be called for each row

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_exec'
2 - Call prevented by SafeMode
3 - Error Processing Callback from within _SQLite_GetTable2d()
4 - Error while converting SQL statement to UTF-8

Remarks

The Callback function must accept 1 parameter and can return $SQLITE_ABORT to stop processing (See example).
The first row in the Callback sequence will be the column names.

Related

_SQLite_GetTable, _SQLite_GetTable2d, _SQLite_Query

Example

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

Local $hQuery, $aRow
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
; Without $sCallback it's a resultless statement
_SQLite_Exec(-1, "Create table tblTest (a,b int,c single not null);" & _
        "Insert into tblTest values ('1',2,3);" & _
        "Insert into tblTest values (Null,5,6);")

Local $d = _SQLite_Exec(-1, "Select rowid,* From tblTest", "_cb") ; _cb will be called for each row

Func _cb($aRow)
    For $s In $aRow
        ConsoleWrite($s & @TAB)
    Next
    ConsoleWrite(@CRLF)
    ; Return $SQLITE_ABORT ; Would Abort the process and trigger an @error in _SQLite_Exec()
EndFunc   ;==>_cb
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; 1     1   2   3
; 2         5   6