I'm trying to figure out how to insert and retrieve a NAN value from an sqlite database. I'm on Mac OS X 10.5 which is using sqlite3 3.4.0.
Obviously, using the sqlite3 command line tool, this is what I get: $ sqlite3 nantest.db SQLite version 3.4.0 Enter ".help" for instructions sqlite> CREATE TABLE IF NOT EXISTS nantest (x double); sqlite> INSERT INTO nantest VALUES(123.4); sqlite> INSERT INTO nantest VALUES(NAN); SQL error: no such column: NAN Ok, so maybe it's my lack of knowledge of SQL syntax, but I really want to do this from code, so on to a more relevant example. Here's a sample of my code: sqlite3* db; sqlite3_open("nantest.db", &db); sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS nantest (x double);", 0,0,0); sqlite3_stmt* stmt; char* nanChars = "INSERT INTO nantest VALUES(?);"; int rc = ::sqlite3_prepare(db, nanChars, -1, &stmt, 0); rc = ::sqlite3_bind_double(stmt, 1, 123.4); rc = ::sqlite3_step(stmt); rc = ::sqlite3_reset(stmt); rc = ::sqlite3_prepare(db, nanChars, -1, &stmt, 0); rc = ::sqlite3_bind_double(stmt, 1, NAN); rc = ::sqlite3_step(stmt); rc = ::sqlite3_reset(stmt); rc = ::sqlite3_prepare(db, "SELECT x FROM nantest;", -1, &stmt, 0); while ((rc = ::sqlite3_step(stmt)) == SQLITE_ROW) { double x = ::sqlite3_column_double(stmt, 0); printf("%5.5f %d\n", x, isnan(x)); } sqlite3_close(db); Binding NAN to a statement works fine. The inserts are successful. But what I put in as NAN comes back out as 0.0. Is there any way to insert a NAN and get a NAN back out of an sqlite database? Thanks, Justin _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users