SQLite Forum

Data Types
Login
Ah, got it.

With regard to all values returned being 5, did you define the column types when you defined the table ?  Or was the table definition like

<code>CREATE TABLE MyTable (first, second, third);</code>

?  Also note that SQLite does not enforce values to be the same type as a column definition.  For instance, you can define a column as INTEGER but put a text value into one row for it.  If that row happens to the first one returned by a query, <code>sqlite3_column_type()</code> will return <code>SQLITE_TEXT</code> for that column.

From the page you quoted …

> The sqlite3_column_type() routine returns the datatype code for the initial data type of the result column. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. The return value of sqlite3_column_type() can be used to decide which of the first six interface should be used to extract the column value. The value returned by sqlite3_column_type() is only meaningful if no automatic type conversions have occurred for the value in question. After a type conversion, the result of calling sqlite3_column_type() is undefined, though harmless. Future versions of SQLite may change the behavior of sqlite3_column_type() following a type conversion.