Function Reference


_SQLite_GetTable

Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query

#include <SQLite.au3>
_SQLite_GetTable ( $hDB, $sSQL, ByRef $aResult, ByRef $iRows, ByRef $iColumns [, $iCharSize = -1] )

Parameters

$hDB An open database, use -1 to use last opened database
$sSQL SQL Statement to be executed
$aResult Passes out the result
$iRows Passes out the amount of 'data' Rows
$iColumns Passes out the amount of columns
$iCharSize [optional] Specifies the maximal size of a data field

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 - Call Prevented by SafeMode
2 - Error returned by _SQLite_Query() in @extended
3 - Error returned by _SQLite_FetchNames() in @extended
4 - Error returned by _SQLite_FetchData() in @extended

Remarks

The number of values inserted into $aResult will be (($iRows) + 1) * ($iColumns) this number is inserted into $aResult[0].
A NULL will be returned as numeric 0.
If you do not need a result (or if there will be none) consider using _SQLite_Exec().

Related

_SQLite_Exec, _SQLite_GetTable2D, _SQLite_Query

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Local $aResult,$iRows,$iColumns,$iRval
_SQLite_Startup ()
If @error Then
MsgBox ($MB_SYSTEMMODAL,"SQLite Error","SQLite3.dll Can't be Loaded!")
Exit - 1
EndIf
ConsoleWrite ("_SQLite_LibVersion="&_SQLite_LibVersion ()&@CRLF )
_SQLite_Open (); Open a :memory: database
If @error Then
MsgBox ($MB_SYSTEMMODAL,"SQLite Error","Can't Load Database!")
Exit - 1
EndIf
; Example Table
;  Name    | Age
;  -----------------------
;  Alice    | 43
;  Bob     | 28
;  Cindy    | 21
If Not _SQLite_Exec (-1,"CREATE TEMP TABLE persons (Name, Age);")= $SQLITE_OKThen _
MsgBox ($MB_SYSTEMMODAL,"SQLite Error",_SQLite_ErrMsg ())
If Not _SQLite_Exec (-1,"INSERT INTO persons VALUES ('Alice','43');")= $SQLITE_OKThen _
MsgBox ($MB_SYSTEMMODAL,"SQLite Error",_SQLite_ErrMsg ())
If Not _SQLite_Exec (-1,"INSERT INTO persons VALUES ('Bob','28');")= $SQLITE_OKThen _
MsgBox ($MB_SYSTEMMODAL,"SQLite Error",_SQLite_ErrMsg ())
If Not _SQLite_Exec (-1,"INSERT INTO persons VALUES ('Cindy','21');")= $SQLITE_OKThen _
MsgBox ($MB_SYSTEMMODAL,"SQLite Error",_SQLite_ErrMsg ())
; Query
$iRval= _SQLite_GetTable (-1,"SELECT * FROM persons;",$aResult,$iRows,$iColumns)
If $iRval= $SQLITE_OKThen
; $aResult Looks Like this:
; [0]  = 8
; [1]  = Name
; [2]  = Age
; [3]  = Alice
; [4]  = 43
; [5]  = Bob
; [6]  = 28
; [7]  = Cindy
; [8]  = 21
_ArrayDisplay ($aResult,"Query Result")
Else
MsgBox ($MB_SYSTEMMODAL,"SQLite Error: "&$iRval,_SQLite_ErrMsg ())
EndIf
_SQLite_Close ()
_SQLite_Shutdown ()

AltStyle によって変換されたページ (->オリジナル) /