Database[SQLite]
Fetch
fetch value of a single column from a prepared SQL statement
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Fetch( statement, column, opts )
statement
-
prepared SQL statement obtained using the Prepare command
column
nonnegint; index of the column
opts
(optional) equation(s) of the form option = value; specify options for the Fetch command
valuetype = string
The valuetype option specifies the type of the value. It may be one of the strings "auto", "blob", "float", "integer", or "text". See the Database[SQLite] help page for more information about type conversion between SQLite and Maple. The default is "auto".
The Fetch command returns the value of a column for the current row.
The column parameter specifies the column index; the leftmost column has index 0.
withDatabaseSQLite:
db≔FileToolsJoinPathkerneloptsdatadir,SQLite,G20-Population.db:
connection≔Opendb:
Select all data from table - prepare statement
stmt≔Prepareconnection,SELECT date, CAN FROM population LIMIT 1
stmt≔SQLite statement,SELECT date, CAN FROM population LIMIT 1
Stepstmt:
Fetch the first column
Fetchstmt,0
1960-12-31
Fetch the second column
Fetchstmt,1
1.7909009×107
Resetstmt
Fetch both columns using all possible values for valuetype option
forvtinauto,blob,float,integer,textdoStepstmt;printvt,Fetchstmt,0,valuetype=vt;printvt,Fetchstmt,1,valuetype=vt;Resetstmtenddo
auto,1960-12-31
auto,1.7909009×107
blob,49575448454950455149
blob,49555748574848574648
float,1960.
float,1.7909009×107
integer,1960
integer,17909009
text,1960-12-31
text,17909009.0
Finalizestmt:
Closeconnection:
The Database[SQLite][Fetch] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
Database[SQLite][Finalize]
Database[SQLite][Prepare]
Database[SQLite][Step]
Download Help Document