函数参考


_SQLite_FetchData

提取 _SQLite_Query() 查询的一行数据

#include <SQLite.au3>
_SQLite_FetchData($hQuery, ByRef $aRow [, $fBinary = False [, $fDoNotFinalize = False]])

参数

$hQuery 传递到 _SQLite_Query() 的查询句柄
$aRow 包含一行数据的一维数组
$fBinary [可选参数] 二进制模式切换($aRow 为二进制字符串数组)
$fDoNotFinalize [可选参数] 如果你需要保留该查询供下一步使用, 切换设置为 TRUE.
(如果是这样, 则调用者必须在关闭数据库前调用 _SQLite_QueryFinalize.)

返回值

成功: 返回 $SQLITE_OK
失败: 返回值可能违反 $SQLITE_* 常量
@error: -1 - SQLite 报告错误 (检查返回值)
1 - 错误调用 SQLite API 'sqlite3_step'
2 - 错误调用 SQLite API 'sqlite3_data_count'
3 - 错误调用 SQLite API 'sqlite3_column_text16'
4 - 错误调用 SQLite API 'sqlite3_column_type'
5 - 错误调用 SQLite API 'sqlite3_column_bytes'
6 - 错误调用 SQLite API 'sqlite3_column_blob'
7 - 调用被安全模式阻止

注意/说明

None.

相关

_SQLite_Query, _SQLite_QueryFinalize

示例/演示


#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