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