FetchRow - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Database[SQLite]

  

FetchRow

  

fetch row from a prepared SQL statement

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

FetchRow( statement, opts )

Parameters

statement

-

prepared SQL statement obtained using the Prepare command

Options

• 

valuetype = string or list(string)

  

The valuetype option specifies the type of the value. It may be one of the strings "auto", "blob", "float", "integer", "text", or a list of those strings. If a list, then the type of a column is specified by the corresponding element in the list; if a string, then it specifies the type of all columns. See the Database[SQLite] help page for more information about type conversion between SQLite and Maple. The default is "auto".

Description

• 

The FetchRow command returns the values of all columns of the current row of a prepared SQL statement.

• 

In order to fetch the next row, call the Step command while it returns RESULT_ROW.

Examples

> 

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 2

stmt≔SQLite statement,SELECT date, CAN FROM population LIMIT 2

(1)
> 

Step⁡stmt:

Fetch the first row

> 

FetchRow⁡stmt

1960-12-31,1.7909009×107

(2)

Fetch the second row, but change the valuetype to "integer" for the first column and "text" for the second

> 

Step⁡stmt:

> 

FetchRow⁡stmt,valuetype=integer,text

1961,18271000.0

(3)
> 

Finalize⁡stmt:

Select all data row by row

> 

stmt≔Prepare⁡connection,SELECT date, CAN FROM population LIMIT 10

stmt≔SQLite statement,SELECT date, CAN FROM population LIMIT 10

(4)
> 

whileStep⁡stmt=RESULT_ROWdoprint⁡FetchRow⁡stmt,valuetype=integerenddo

1960,17909009

1961,18271000

1962,18614000

1963,18964000

1964,19325000

1965,19678000

1966,20048000

1967,20412000

1968,20744000

1969,21028000

(5)
> 

Finalize⁡stmt:

> 

Close⁡connection:

Compatibility

• 

The Database[SQLite][FetchRow] 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]