Results 1 to 2 of 2

Thread: Execute multiple sql command in SQLITE3

  1. #1
    Join Date
    Feb 2013
    Location
    India
    Posts
    153
    Thanks
    27
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Exclamation Execute multiple sql command in SQLITE3

    Hii,

    I want to execute multiple sql query via single query command.

    I am using SQLITE3 on windows7.

    Currently i am working with transaction but failed.
    my transaction code is:

    Qt Code:
    1. // create transaction command
    2. QString query;
    3. query.append("BEGIN TRANSACTION; DELETE FROM container WHERE TXN_ID == 'TXN_2'; DELETE FROM txn_journal WHERE TXN_ID = 2; COMMIT;");
    4.  
    5. // execute sqlite query
    6. QSqlQuery sqlQuery;
    7. sqlQuery.exec(query);
    To copy to clipboard, switch view to plain text mode 

    i am just searching the another way to execute multiple sqlite query.
    If you have any idea about executing multiple sqlite query please suggest me.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Execute multiple sql command in SQLITE3

    You can't. You have to call exec() for every statement. But watch out to better use QSqlDatabase transaction functionality instead of pure SQL 'BEGIN TRANSACTION;'.

Similar Threads

  1. Execute sql queries on multiple databases
    By Cyrebo in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2013, 22:32
  2. how to execute multiple commands at a time
    By PHANI in forum Qt Programming
    Replies: 4
    Last Post: 22nd February 2012, 10:01
  3. Replies: 1
    Last Post: 17th May 2010, 17:15
  4. How do I execute an .schema command using Qt's SQLITE driver?
    By danielperaza in forum Qt Programming
    Replies: 4
    Last Post: 5th April 2010, 21:21
  5. Ho to use signals and slots to execute a command?
    By claudio-cit in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2008, 23:01

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.