tags:

views:

59

answers:

1
sqlite3_stmt *updateStmt = nil;
    if (updateStmt == nil) 
    {
        const char *sql = " update PPM set amount = ? ";
        if (sqlite3_prepare_v2(appDelegate.PPMdatabase, sql, -1,&updateStmt, NULL)!= SQLITE_OK)
        {
            NSAssert (0,@"Error while creating update statement. '%s'",sqlite3_errmsg(appDelegate.PPMdatabase));
        }
    }
    sqlite3_bind_double (updateStmt,1, Val);
if (SQLITE_DONE != sqlite3_step(updateStmt))
    {
        NSAssert(0,@"Error while updating.'%s'",sqlite3_errmsg(appDelegate.PPMdatabase));
    }
    sqlite3_reset(updateStmt);

I get error: error while updating.unkown error

+1  A: 

You should be comparing sqlite3_step() against SQLITE_OK and then using the extended result codes for finer discrimination. Even the documentation calls this scheme "goofy".

The reason you are getting an "Unknown Error" is probably because you are calling sqlite3_errmsg when there was no error (that is, step() returned OK).

msw
can you help me how to use where clause in the query?
And if i compare it against SQLITE_OK the program crashes.
I don't see a WHERE clause anywhere, and if changing a constant operand to the `!=` operator causes your program to crash, I can't be of any use at all. You might want to try the "teddy bear" method of debugging: Grab a teddy bear (or a brick, etc.) and explain to it what you are trying to do. You need practice explaining your problems and a brick is surprisingly good help at this. I'm not kidding.
msw
hey thanks my problem of where clause is solved. And it works perfectly ok even with the sqlite3_step() being compared to the SQLIE_DONE. Thanks for all your help.