Expand/Shrink

sqlite3_column

Definition: include pSQLite.e

integer res = sqlite3_column_count(sqlite3_stmt pStmt)
-- or --
integer res = sqlite3_data_count(sqlite3_stmt pStmt)

-- and --

integer res = sqlite3_column_type(sqlite3_stmt pStmt, integer column)
-- or --
string res = sqlite3_column_decltype(sqlite3_stmt pStmt, integer column)
-- or --
string res = sqlite3_column_name(sqlite3_stmt pStmt, integer column)

-- and --

integer res = sqlite3_column_int(sqlite3_stmt pStmt, integer column)
-- or --
atom res = sqlite3_column_double(sqlite3_stmt pStmt, integer column)
-- or --
string res = sqlite3_column_text(sqlite3_stmt pStmt, integer column)
-- or --
object res = sqlite3_column_blob(sqlite3_stmt pStmt, integer column)
Description: These routines return information about a single column of the current result row of a query.

pStmt: A pointer to the sqlite3_stmt structure returned from sqlite3_prepare().
column: a number in the range 1..sqlite3_column_count(pStmt).

The sqlite3_column_count() function returns the number of columns in the result set returned by the prepared SQL statement.
It can be called at any time after sqlite3_prepare(), and returns 0 if pStmt does not return data (for example an UPDATE).

The sqlite3_data_count() function returns the number of values in the current row of the result set.
It works similarly to sqlite3_column_count() except that it only works following sqlite3_step().
After a call to sqlite3_step() that returns SQLITE_ROW, this routine will return the same value as the sqlite3_column_count() function.
After sqlite3_step() has returned an SQLITE_DONE, SQLITE_BUSY or an error code, or before sqlite3_step() has been called on pStmt, this routine returns 0, whereas sqlite3_column_count() will continue to return the number of columns in the result set.

The sqlite3_column_type() function returns the datatype for the value in the specified column (1-based).
The return value is one of these (as declared in pSQLite.e):

global constant SQLITE_INTEGER  = 1,
                SQLITE_FLOAT    = 2,
                SQLITE_TEXT     = 3,
                SQLITE_BLOB     = 4,
                SQLITE_NULL     = 5

The sqlite3_column_decltype() routine returns text which is the declared type of the column in the CREATE TABLE statement.
For an expression, the return type is an empty string.

sqlite3_column_name() returns the name of the Nth column.

The sqlite3_column_int() function returns an integer.

The sqlite3_column_double() function returns an atom.

The sqlite3_column_text() function returns a string.

The sqlite3_column_blob() function returns any phix object, after deserialization.
Note that sqlite3_column_blob (or more accurately that way it is currently wrapped in pSQLite.e) does not distinguish between a NULL meaning nothing stored and a NULL or zero that has actually been stored.
pwa/p2js: Not supported
Comments: It is not necessary to retrieve data in the format specify by sqlite3_column_type().
If a different format is requested, the data is converted automatically.
Example: See sqlite3_prepare