Results 1 to 4 of 4

Thread: DROP TABLE does not delete table

  1. #1
    Join Date
    Sep 2009
    Location
    Kranj, Slovenia
    Posts
    25
    Thanks
    10
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default 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?

  3. #3
    Join Date
    Sep 2009
    Location
    Kranj, Slovenia
    Posts
    25
    Thanks
    10
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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?

  4. #4
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default 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.

Similar Threads

  1. drag and drop to change order in a table
    By knobby67 in forum Newbie
    Replies: 0
    Last Post: 11th September 2014, 12:57
  2. QComboBox drop down list as table
    By ROCKSTAR in forum Qt Programming
    Replies: 9
    Last Post: 11th February 2014, 11:22
  3. Replies: 1
    Last Post: 8th June 2011, 15:13
  4. How to delete results of QSqlQuery from table ?
    By homerun4711 in forum Newbie
    Replies: 2
    Last Post: 14th February 2011, 23:50
  5. Drop on table and widget
    By core_st in forum Newbie
    Replies: 2
    Last Post: 15th November 2010, 22:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.