sqlite3prepare crash

Discussion in 'iPhone/iPad Programming' started by Picapau, Dec 22, 2008.

  1. macrumors newbie

    Joined:
    Dec 10, 2008
    #1
    Hi,

    I have a random crash that Ive been struggling around with for days but I cant find the root cause. It happens when I dehydrate an item from the database. The code part is:

    - (void) dehydrate {

    if(dirty) {
    if (dehydrate_statement == nil) {
    const char *sql = "UPDATE items SET status=?, vID=? WHERE id=?";
    if (sqlite3_prepare_v2(database, sql, -1, &dehydrate_statement, NULL) != SQLITE_OK) {
    NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
    }
    }
    sqlite3_bind_text(dehydrate_statement, 1, [status UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(dehydrate_statement, 2, [vID UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_int(dehydrate_statement, 3, pk);
    int success = sqlite3_step(dehydrate_statement);
    // Reset the query for the next use.
    sqlite3_reset(dehydrate_statement);
    // Handle errors.
    if (success != SQLITE_DONE) {
    NSAssert1(0, @"Error: failed to save priority with message '%s'.", sqlite3_errmsg(database));
    }
    dirty = NO;
    }

    }
     

Share This Page