Database[SQLite] - Maple Programming Help

Home : Support : Online Help : Connectivity : Database Package : SQLite : Database/SQLite/ColumnCount

Database[SQLite]

 ColumnCount
 - get number of columns in prepared statement

 Calling Sequence ColumnCount( statement )

Parameters

 statement - prepared statement obtained using Prepare command

Description

 • The ColumnCount command returns number of columns in prepared statement.

Examples

 > $\mathrm{with}\left(\mathrm{Database}[\mathrm{SQLite}]\right)$
 $\left[{\mathrm{Attach}}{,}{\mathrm{Bind}}{,}{\mathrm{ClearBindings}}{,}{\mathrm{Close}}{,}{\mathrm{ColumnCount}}{,}{\mathrm{ColumnNames}}{,}{\mathrm{Execute}}{,}{\mathrm{Fetch}}{,}{\mathrm{FetchAll}}{,}{\mathrm{FetchRow}}{,}{\mathrm{Finalize}}{,}{\mathrm{Open}}{,}{\mathrm{Opened}}{,}{\mathrm{Prepare}}{,}{\mathrm{RESULT_BUSY}}{,}{\mathrm{RESULT_DONE}}{,}{\mathrm{RESULT_ROW}}{,}{\mathrm{Reset}}{,}{\mathrm{Step}}\right]$ (1)
 > $\mathrm{db}≔\mathrm{FileTools}[\mathrm{JoinPath}]\left(\left[\mathrm{kernelopts}\left('\mathrm{datadir}'\right),"SQLite","G20-Population.db"\right]\right):$
 > $\mathrm{connection}≔\mathrm{Open}\left(\mathrm{db}\right):$

Select all data from table - prepare statement

 > $\mathrm{stmt}≔\mathrm{Prepare}\left(\mathrm{connection},"SELECT * FROM population"\right)$
 ${\mathrm{stmt}}{≔}{"SQLite statement"}{,}{"SELECT * FROM population"}$ (2)

Number of columns

 > $\mathrm{ColumnCount}\left(\mathrm{stmt}\right)$
 ${21}$ (3)

Fetch all rows

 > $\mathrm{FetchAll}\left(\mathrm{stmt}\right)$
 $\left[\begin{array}{c}{\mathrm{53 x 21}}{\mathrm{Matrix}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{C_order}}\end{array}\right]$ (4)
 > $\mathrm{Finalize}\left(\mathrm{stmt}\right):$
 > $\mathrm{Close}\left(\mathrm{connection}\right):$

Compatibility

 • The Database[SQLite][ColumnCount] command was introduced in Maple 18.