是否“插入"在 SQLite 中返回 SQLITE_OK 还是 SQLITE_DONE? [英] Does "insert" in SQLite return SQLITE_OK or SQLITE_DONE?
本文介绍了是否“插入"在 SQLite 中返回 SQLITE_OK 还是 SQLITE_DONE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果成功,SQLite 中的语句插入"返回什么?
What does statement "insert" in SQLite return in case of success?
我一直认为它应该是 SQLITE_DONE,但最近在我的日志中我发现了以下字符串:
I always believed that it should be SQLITE_DONE, but recently in my logs I found out the following string:
sqlite3_step error: 'not an error'
这里是记录提到的字符串的代码:
And here is the code that logs the mentioned string:
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);
我想知道,为什么它在大多数情况下都有效.我应该将代码中的 SQLITE_DONE 更改为 SQLITE_OK 吗?
I am wondering, why does it work in most cases. Should I change SQLITE_DONE in my code to SQLITE_OK?
谢谢.
推荐答案
SQLITE_DONE
SQLITE_DONE
http://www.sqlite.org/c3ref/step.html
您也可以尝试打印错误代码以找出问题所在.
You could also try printing out the error code to find out what the problem is.
这篇关于是否“插入"在 SQLite 中返回 SQLITE_OK 还是 SQLITE_DONE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文