如果成功,SQLite中的"insert"语句会返回什么?
我一直认为它应该是SQLITE_DONE,但最近在我的日志中我发现了以下字符串:
sqlite3_step error: 'not an error'
Run Code Online (Sandbox Code Playgroud)
以下是记录上述字符串的代码:
prepareStatement(addTranslationStmt2, "INSERT INTO translations(lang1_wordid, lang2_wordid) VALUES(?, ?)");
if (!addTranslationStmt2) return -2;
sqlite3_bind_int(addTranslationStmt2, 1, word_id);
sqlite3_bind_int(addTranslationStmt2, 2, translation_id);
if(sqlite3_step(addTranslationStmt2) != SQLITE_DONE)
{
NSLog(@"sqlite3_step error: '%s'", sqlite3_errmsg(database));
sqlite3_reset(addTranslationStmt2);
return -1;
}
sqlite3_reset(addTranslationStmt2);
Run Code Online (Sandbox Code Playgroud)
我想知道,为什么它在大多数情况下都有效.我应该将代码中的SQLITE_DONE更改为SQLITE_OK吗?
谢谢.