PDA

View Full Version : QDatabase::transaction()



sunil.thaha
3rd February 2006, 12:57
How do we know that the trasaction function is called ?
And is there any side effects if It's called more than once as shown below


QSqlDatabase* db = QSqlDatabase::database();
db->transaction();
// ......
// ......
db->transaction();
// ......
// ......
db->rollback();

Everall
3rd February 2006, 13:58
Hello ,


How do we know that the trasaction function is called ?
You could use something like this :


bool transactionIsActive;
transactionIsActive =db->transaction();

if transactionIsActive {
...
}



And is there any side effects if It's called more than once as shown below
IMO it will rollback to the first transaction. As if the second will be ignored.
You could test this in your code.

Cheers

sunil.thaha
3rd February 2006, 14:15
IMO it will rollback to the first transaction. As if the second will be ignored.
You could test this in your code.


Yes it's ignoring all calls to transaction() untill a commit()/ rollback is called.

Thanks