SQLite SQLite column can't be updated to any value but zero (real type)
Posted
by
user1065320
on Stack Overflow
See other posts from Stack Overflow
or by user1065320
Published on 2011-11-25T09:37:37Z
Indexed on
2011/11/25
9:50 UTC
Read the original article
Hit count: 219
Hi I'm trying to create a three fields table (date,text,real), I can insert and update the first two fields but can't set or update the last one.
createSQL = @"CREATE TABLE IF NOT EXISTS ACTIVITIES (MYDATE DATETIME PRIMARY KEY, ACTIVITY TEXT , LENGTH REAL);";
try to insert
char *update = "INSERT OR REPLACE INTO ACTIVITIES (MYDATE, ACTIVITY , LENGTH) VALUES (?, ? ,?);";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(database, update , -1, &stmt, nil) == SQLITE_OK)
{
sqlite3_bind_double(stmt, 1, valueToWrite);
sqlite3_bind_text(stmt, 2, [task UTF8String], -1, NULL);
sqlite3_bind_double(stmt, 3, 1.5);
}
if (sqlite3_step(stmt) != SQLITE_DONE)
{
NSAssert1(0, @"Error updating table: %s", errorMsg);
}
sqlite3_finalize(stmt);
sqlite3_close(database);
The first two values are updated but the last one remains 0 even if I'm writing a value like 1.5 or put a double variable with a different value
Thanks
© Stack Overflow or respective owner