Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

## Declared Datatype Of A Query Result

>     const char *sqlite3_column_decltype(sqlite3_stmt*,int);
>     const void *sqlite3_column_decltype16(sqlite3_stmt*,int);

The first parameter is a prepared statement. If this statement is a SELECT statement and the Nth column of the returned result set of that SELECT is a table column (not an expression or subquery) then the declared type of the table column is returned. If the Nth column of the result set is an expression or subquery, then a NULL pointer is returned. The returned string is always UTF-8 encoded.

For example, given the database schema:

CREATE TABLE t1(c1 VARIANT);

and the following statement to be compiled:

SELECT c1 + 1, c1 FROM t1;

this routine would return the string "VARIANT" for the second result column (i==1), and a NULL pointer for the first result column (i==0).

SQLite uses dynamic run-time typing. So just because a column is declared to contain a particular type does not mean that the data stored in that column is of the declared type. SQLite is strongly typed, but the typing is dynamic not static. Type is associated with individual values, not with the containers used to hold those values.

### Invariants:

H13761 | A successful call to sqlite3_column_decltype(S,N) returns a zero-terminated UTF-8 string containing the declared datatype of the table column that appears as the Nth column (numbered from 0) of the result set to the prepared statement S.
H13762 | A successful call to sqlite3_column_decltype16(S,N) returns a zero-terminated UTF-16 native byte order string containing the declared datatype of the table column that appears as the Nth column (numbered from 0) of the result set to the prepared statement S.
H13763 | If N is less than 0 or N is greater than or equal to the number of columns in the prepared statement S, or if the Nth column of S is an expression or subquery rather than a table column, or if a memory allocation failure occurs during encoding conversions, then calls to sqlite3_column_decltype(S,N) or sqlite3_column_decltype16(S,N) return NULL.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/08/11 17:57:43 UTC