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.
with⁡DatabaseSQLite:
db≔FileToolsJoinPath⁡kernelopts⁡datadir,SQLite,G20-Population.db:
connection≔Open⁡db:
Select all data from table - prepare statement
stmt≔Prepare⁡connection,SELECT date, CAN FROM population LIMIT 1
stmt≔SQLite statement,SELECT date, CAN FROM population LIMIT 1
Step⁡stmt:
Fetch the first column
Fetch⁡stmt,0
1960-12-31
Fetch the second column
Fetch⁡stmt,1
1.7909009×107
Reset⁡stmt
Fetch both columns using all possible values for valuetype option
forvtinauto,blob,float,integer,textdoStep⁡stmt;print⁡vt,Fetch⁡stmt,0,valuetype=vt;print⁡vt,Fetch⁡stmt,1,valuetype=vt;Reset⁡stmtenddo
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
Finalize⁡stmt:
Close⁡connection:
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