Does "embed" in SQLite return SQLITE_OK or SQLITE_DONE?

What does the insertion expression do in SQLite return if successful?

I always thought it should be SQLITE_DONE, but recently in my logs I found the following line:

sqlite3_step error: 'not an error'

And here is the code that registers the specified 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);

I wonder why this works in most cases. Should I change SQLITE_DONE in my code to SQLITE_OK?

Thanks.

+3
source share
3 answers

SQLITE_DONE

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

You can also try printing an error code to find out what the problem is.

+8
source

In such cases, I like to watch code samples. Here are some good ones:

http://sqlite.phxsoftware.com/forums/p/76/6659.aspx

SQLite Result Codes Reference SQLITE_OK . , 0, (.. , ).

, , , , , . , , SQLITE_OK.

sqlite3_step() , "v2" sqlite3_prepare_v2() sqlite3_prepare16_v2() sqlite3_prepare() sqlite3_prepare16().

SQLITE_BUSY, SQLITE_DONE, SQLITE_ROW, SQLITE_ERROR, SQLITE_MISUSE. "v2" .

+3

Switching from Debug to Release resolved the issue for me.

+1
source

Source: https://habr.com/ru/post/1711403/


All Articles