Simon Slavin <slav...@bigfraud.org> wrote:
> I was attempting to find a value which would always coerce directly to the 
> affinity of the column, so when you read it back out
> it would always be the 'proper' type.  My theory would be that this one value 
> could be used to betray the affinity of every
> column in a table.  
> 
> Unfortunately I don't think I can tell REAL from NUMERIC with the same value 
> that can tell REAL from INTEGER.

If you write 1, REAL will store it as 1.0 (SQLITE_FLOAT) while INTEGER and 
NUMERIC would store it as 1 (SQLITE_INTEGER). This technique won't be able to 
tell INTEGER from NUMERIC anyway: "A column that uses INTEGER affinity behaves 
the same as a column with NUMERIC affinity. The difference between INTEGER and 
NUMERIC affinity is only evident in a CAST expression."

It'll also be difficult yo detect a column with affinity NONE.

I suspect that, by this point, it would be easier to use 
sqlite3_column_decltype and do a bit of string manipulation to calculate column 
affinity the same way SQLite does.
-- 
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to