gpt4 book ai didi

sqlite - SQLite 中的 "insert"是否返回 SQLITE_OK 或 SQLITE_DONE?

转载 作者:行者123 更新时间:2023-12-03 15:58:32 25 4
gpt4 key购买 nike

如果成功,SQLite 中的语句“插入”会返回什么?

我一直认为它应该是 SQLITE_DONE,但最近在我的日志中我发现了以下字符串:

sqlite3_step error: 'not an error'

这是记录提到的字符串的代码:
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 吗?

谢谢。

最佳答案

SQLITE_DONE

http://www.sqlite.org/c3ref/step.html

您也可以尝试打印出错误代码以找出问题所在。

关于sqlite - SQLite 中的 "insert"是否返回 SQLITE_OK 或 SQLITE_DONE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1053020/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com