加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite中的“insert”是返回SQLITE_OK还是SQLITE_DONE?

发布时间:2020-12-12 18:52:42 所属栏目:百科 来源:网络整理
导读:如果成功,SQLite中的“insert”语句会返回什么? 我一直认为它应该是SQLITE_DONE,但最近在我的日志中我发现了以下字符串: sqlite3_step error: 'not an error' 以下是记录上述字符串的代码: prepareStatement(addTranslationStmt2,"INSERT INTO translatio
如果成功,SQLite中的“insert”语句会返回什么?

我一直认为它应该是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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读