PDA

View Full Version : Execute multiple sql command in SQLITE3



karankumar1609
29th May 2013, 13:05
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:



// create transaction command
QString query;
query.append("BEGIN TRANSACTION; DELETE FROM container WHERE TXN_ID == 'TXN_2'; DELETE FROM txn_journal WHERE TXN_ID = 2; COMMIT;");

// execute sqlite query
QSqlQuery sqlQuery;
sqlQuery.exec(query);



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.

Lykurg
30th May 2013, 12:43
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;'.