Sometimes when I try to do two SQL functions back to back, i.e.: select then immediately insert, or delete then select, etc, I get this error:
"Error occurred calling next on a PLSqliteResultSet. SQLite error: 'database is locked' for 'INSERT INTO groups (groupname) VALUES (?)'";
Based on what I've been able to find, it is happening because the first hit to the DB is not complete before trying to do the second one. Although I understand why it is happening, I am not sure how to prevent it. Originally I had been doing the back to back functions on the same connection. Then I tried closing the first connection and opening a new one. That didn't solve the problem.
Is there a best-practice way to precent this error?
Application type: mobile. Titanium SDK: 1.8.2. Platform & version: iOS 5.x. Device: iOS simulator. Host Operating System: OSX 10.7.3. Titanium Studio: 2.0.1
i don't think commits around select statements do anything? I do see you haven't closed nameCount though. that should be closed as well
var nameCount = dbc.execute('SELECT count (*) AS rowCount FROM groups WHERE groupname = ?', e.values.GroupName); var count = nameCount.fieldByName('rowCount'); nameCount.close(); dbc.close();
try using db.close() after each statement. Could also make sure your inserts/deletes are completed by using
db.execute('BEGIN TRANSACTION'); INSERTS/DELETES HERE db.execute('COMMIT TRANSACTION');
I have the same problem here! Any update about this problem? thank you!
Think you can help? Login to answer this question!