Can anyone provide any input on this error. I am trying to insert into table using Objective C.
While I am doing this, I am getting an error SQLite Busy. Why this is happening?
exceptioniphoneobjective-csqlite
Can anyone provide any input on this error. I am trying to insert into table using Objective C.
While I am doing this, I am getting an error SQLite Busy. Why this is happening?
Best Solution
If you get as a result when invoking an sqlite3 function the error code SQLITE_BUSY, this means as observed by drdaeman that the db has been locked by the same process or by one thread within your process.
The proper way to deal with this situation is to try the operation in a loop, and if the return code is still SQLITE_BUSY, to wait for some time (you decide the timeout value) and then retry the operation in the next loop iteration.
For instance, the following code snippet is taken from the Objective C wrapper FMDB (http://code.google.com/p/flycode/source/browse/trunk/fmdb) shows how to prepare a statement for a query taking into account that some operations may return SQLITE_BUSY:
By the way, if you need to access sqlite, FMDB is very handy and much simpler to use with respect to direct access through the native C APIs.