When I run this code in iPhone simulator ,I can not delete record from DB . If I run this query in SQLite DB Browser it works well. Here is my code
SQLiteDB *sqliteConnect=[[SQLiteDB alloc] init];
sqlite3 *database;
if(sqlite3_open([sqliteConnect.databasePath UTF8String], &database)==SQLITE_OK)
{   
    sqlite3_stmt *compiledstatement;
    const char *sqlstmt="delete from searchHistory where id = (select min(id) from searchHistory) ";
    if(sqlite3_prepare_v2(database, sql开发者_StackOverflowstmt, -1, &compiledstatement, NULL)==SQLITE_OK)
    {
        sqlite3_step(compiledstatement);
        if(SQLITE_DONE != sqlite3_step(compiledstatement))
            NSAssert1(0,@"Error while creating delete statement => %s",sqlite3_errmsg(database) );
    }
    NSLog(@"delete DONE");
    sqlite3_finalize(compiledstatement);
}
sqlite3_close(database);
When I run using debugger , I get following error =>
2011-04-08 08:42:34.049 MyApp[1838:20b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error while creating delete statement => not an error'
SQLiteDB is my class which contains logic for init & checkAndCopyDB methods. My DB gets copied in documents directory. Other DB operations works fine. Please help me. Thanks
you're calling sqlite3_step twice?
Try this :
{
    int result = sqlite3_step(compiledstatement);
    if(SQLITE_DONE != result)
        NSAssert1(0,@"Error while creating delete statement => %s",sqlite3_errmsg(database) );
 }
Perhaps try:
if(SQLITE_DONE != sqlite3_step(compiledstatement))
    NSAssert1(0,@"Error while creating delete statement => %s",sqlite3_errmsg(database));
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论