monsabre
monsabre

Reputation: 2099

sqlite3_bind_text for null string

I use the codes to access sqlite

sqlite3_bind_text(statement,1,[myString UTF8String],-1,SQLITE_TRANSIENT);

It works. But if myString is NULL, it always causes updating the record in table failed. (or nothing changed) How to process when myStrign is NULL?

Welcome any comment

Thanks

Upvotes: 1

Views: 4365

Answers (1)

Doug Currie
Doug Currie

Reputation: 41180

Use sqlite3_bind_null(statement, 1); when your string is NULL.

if (myString)
    sqlite3_bind_text(statement,1,[myString UTF8String],-1,SQLITE_TRANSIENT);
else 
    sqlite3_bind_null(statement,1);

Upvotes: 7

Related Questions