Function Reference


Executes a SQLite query, does not handle results

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


$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


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.


_SQLite_GetTable, _SQLite_GetTable2D, _SQLite_Query


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

Local $hQuery
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

; 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


; Output:
;rowid  a       b       c
; 1             1       2       3
; 2                     5       6

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