views:

15

answers:

1

if (insert_statement == nil) {

static char *query = "INSERT INTO iteminfo (itemname, friendid) VALUES(?,?) where itemid=?";

if (sqlite3_prepare_v2(database, query, -1, &insert_statement, NULL) != SQLITE_OK) {
    NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}

i am new to Objective C programming....

i am trying this code to insert some values into database based on where condition, but there is a exception in preparing the insert statement the waring which i am getting is "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error: failed to prepare statement with message 'near "WHERE": syntax error'.'" Please help me out of this... issue..

+1  A: 

You can't use INSERT INTO with a WHERE clause - INSERT adds a new row, not update an existing one. Perhaps you meant UPDATE?

K Prime
Or are you trying to do a REPLACE?
Alex