當我在iPhone模擬器中運行此代碼時,我無法從數據庫中刪除記錄。如果我在SQLite數據庫瀏覽器中運行這個查詢,它效果很好。這裏是我的代碼無法從SQLite中刪除記錄iPhone
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, sqlstmt, -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);
當我運行使用調試器,我得到以下錯誤=>
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是我的類,它包含init的& checkAndCopyDB方法的邏輯。我的數據庫被複制到文檔目錄中。其他數據庫操作正常。請幫幫我。謝謝
=>謝謝...它完美.. – iOSAppDev 2011-04-07 16:52:54