Name

sqlite3_column_xxx() — Get a results column value

Definition

const void*          sqlite3_column_blob(   sqlite3_stmt* stmt, int cidx );
double               sqlite3_column_double( sqlite3_stmt* stmt, int cidx );
int                  sqlite3_column_int(    sqlite3_stmt* stmt, int cidx );
sqlite3_int64        sqlite3_column_int64(  sqlite3_stmt* stmt, int cidx );
const unsigned char* sqlite3_column_text(   sqlite3_stmt* stmt, int cidx );
const void*          sqlite3_column_text16( sqlite3_stmt* stmt, int cidx );
sqlite3_value*       sqlite3_column_value(  sqlite3_stmt* stmt, int cidx );
stmt

A prepared and executed statement.

cidx

A column index. The first column has an index of zero (0).

Returns

The requested value.

Description

These functions extract values from a prepared statement. Values are available any time sqlite3_step() returns SQLITE_ROW. If the requested type is different than the actual underlying value, the value will be converted using the conversion rules defined by Table 7-1.

SQLite will take care of all memory management for the buffers returned by these functions. Pointers returned may become invalid at the next call to sqlite3_step(), sqlite3_reset(), sqlite3_finalize(), or any sqlite3_column_xxx() call on the same column index. Pointers can also become invalid because of a call to one of the sqlite3_column_bytes() functions.

Be warned that sqlite3_column_int() will clip any integer values to 32 bits. If the database contains values that cannot be represented by a 32-bit signed integer, it is safer to use sqlite3_column_int64(). The ...

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.