Hi,
how can i test if a TRANSACTION is ok?
I try this:
qDebug
() << db.
driver()->hasFeature
(QSqlDriver::Transactions);
//true
QSqlDatabase db = QSqlDatabase::database();
QSqlQuery q(db);
qDebug() << db.driver()->hasFeature(QSqlDriver::Transactions); //true
To copy to clipboard, switch view to plain text mode
so SQLite aided transactions
But the COMMIT for a TRANSACTION is always TRUE. Here a example:
db.transaction();
qDebug() << q.exec("SELECT;"); //false
q.clear();
if(!db.commit()){
db.rollback();
}
QSqlDatabase db = QSqlDatabase::database();
db.transaction();
QSqlQuery q;
qDebug() << q.exec("SELECT;"); //false
q.clear();
if(!db.commit()){
db.rollback();
}
To copy to clipboard, switch view to plain text mode
The COMMIT is TRUE and i try this:
qDebug() << db.driver()->beginTransaction(); //true
qDebug() << q.exec("SELECT;"); //false
qDebug() << db.driver()->commitTransaction();//true
QSqlDatabase db = QSqlDatabase::database();
QSqlQuery q(db);
qDebug() << db.driver()->beginTransaction(); //true
qDebug() << q.exec("SELECT;"); //false
qDebug() << db.driver()->commitTransaction();//true
To copy to clipboard, switch view to plain text mode
and
qDebug() << q.exec("BEGIN TRANSACTION"); //true
qDebug() << q.exec("SELECT;"); //false
qDebug() << q.exec("COMMIT");//true
qDebug() << q.exec("BEGIN TRANSACTION"); //true
qDebug() << q.exec("SELECT;"); //false
qDebug() << q.exec("COMMIT");//true
To copy to clipboard, switch view to plain text mode
The ROLLBACK works fine, but i cant verifying the COMMIT respectively the TRANSACTION!
Bookmarks