I use Sqlite3 in my application for iPhone, I get some unwanted rollbacks, apparently randomly. However, I do not know if this is due to the fact that I am not completing the statements with help sqlite3_finalize, since, as far as I know, it sqlite3_execwill take care of this.
I also found several SELECT s sqlite3_prepare_v2that I did not complete, so I know I have to complete them, but should I do the same with the tags in sqlite3_exec?
One of my statements:
NSString *query=@"UPDATE books SET title='newName' WHERE id='21';";
if ((result=sqlite3_open([database UTF8String], &_database))==SQLITE_OK) {
result=sqlite3_exec(_database, [query UTF8String],NULL,NULL,&errorMsg);
if (result!=SQLITE_OK) {
printf("\n%s",errorMsg);
sqlite3_free(errorMsg);
}
sqlite3_close(_database);
}
Do I have sqlite3_finalize(result)to close the database?
source
share