DROP TABLE does not delete table
Hi,
I am trying to delete existing table inside SQLITE database. The database is open. I can execute select, insert, update data in the table. I can alter the table with both rename and add column. But I can not delete the table using "DROP TABLE IF EXISTS oldtable". The lastError() gives the next error: "database table is locked Unable to fetch row".
Why I can execute every other query possible but DROP TABLE?
Thanks! Luka
Re: DROP TABLE does not delete table
Do you have a QSqlQuery that is not finished? i.e. Make sure you QSqlQuery::finish() any QSqlQuery object you have created before you attempt to drop the table.
Edit: Could also be a transaction is active. i.e. Did you "begin transaction" but haven't done a commit or rollback yet?
Re: DROP TABLE does not delete table
Apparently something is active as in not finisher, but I can not locate the query that is holding a lock on the database. If I close and reopen the database connection, the query works... Is there a way to check which query is active?
Re: DROP TABLE does not delete table
I am not aware of a way to programmatically determine which query may still be active, but you can use QSqlQuery::isActive() on each QSqlQuery you create on the heap to find out which one it is. QSqlQuery's created on the stack will of course go out of scope when the method returns, so unless the QSqlQuery in question is in the same method where you're trying to drop the table, it's likely one that you have created on the heap, etc.