Small. Fast. Reliable.
Choose any three.

SQLite C Interface

Column Names In A Result Set

const char *sqlite3_column_name(sqlite3_stmt*, int N);
const void *sqlite3_column_name16(sqlite3_stmt*, int N);

These routines return the name assigned to a particular column in the result set of a SELECT statement. The sqlite3_column_name() interface returns a pointer to a zero-terminated UTF8 string and sqlite3_column_name16() returns a pointer to a zero-terminated UTF16 string. The first parameter is the prepared statement that implements the SELECT statement. The second parameter is the column number. The left-most column is number 0.

The returned string pointer is valid until either the prepared statement is destroyed by sqlite3_finalize() or until the next call sqlite3_column_name() or sqlite3_column_name16() on the same column.

If sqlite3_malloc() fails during the processing of either routine (for example during a conversion from UTF-8 to UTF-16) then a NULL pointer is returned.

The name of a result column is the value of the "AS" clause for that column, if there is an AS clause. If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next.

Invariants:

F13721 A successful invocation of the sqlite3_column_name(S,N) interface returns the name of the Nth column (where 0 is the left-most column) for the result set of prepared statement S as a zero-terminated UTF-8 string.
F13723 A successful invocation of the sqlite3_column_name16(S,N) interface returns the name of the Nth column (where 0 is the left-most column) for the result set of prepared statement S as a zero-terminated UTF-16 string in the native byte order.
F13724 The sqlite3_column_name() and sqlite3_column_name16() interfaces return a NULL pointer if they are unable to allocate memory memory to hold there normal return strings.
F13725 If the N parameter to sqlite3_column_name(S,N) or sqlite3_column_name16(S,N) is out of range, then the interfaces returns a NULL pointer.
F13726 The strings returned by sqlite3_column_name(S,N) and sqlite3_column_name16(S,N) are valid until the next call to either routine with the same S and N parameters or until sqlite3_finalize(S) is called.
F13727 When a result column of a SELECT statement contains an AS clause, the name of that column is the indentifier to the right of the AS keyword.

See also lists of Objects, Constants, and Functions.


This page last modified 2008/01/31 20:37:13 UTC