Strange behavior with IBDac Transactions ?
Posted: Sat 18 Oct 2014 18:49
Strange behavior with IBDAC 5.4.11 Transactions !
"Delphi XE3 Update2 17.0.4770.56661 win 7 Pro - 32/64 bits"
Hi,
It has been 10 years, i have worked with dbExpress.
I have just baught, last week, the great IBDAC Components for it's very very fast speed ! Thanks to DevArt Team
I have somme difficulties to understand Transactions with IBDAC.
(Sorry for this topic : I could'nt find the solution on your Forum).
So, let see the problem :
1. Transactions with dbExpress are simple :
Just Start one Global Transaction, work with it, then Commit (or RollBack) :
SQLConnection1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
SQLConnection1.commit;
except
SQLConnection1.RollBack;
exit;
end;
After commiting/ Rollbacking, the Connection (SQLConnection1) will not be in Transacion Yet (this is the correct beahvior).
2. With IBDAC the story is different !
Here is what I found in my great confusion :
Put an :
- IBCConnection1, with Autocommit = False
- IBCTransaction1
- IBCQuery1 with Autocommit = False and Transaction = IBCTransaction1
Exmple 1 :
=======
if you start this Explicit Transaction :
IBCTransaction1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
IBCTransaction1.commit;
except
IBCTransaction1.RollBack;
exit;
end;
the IBCConnection1.InTransaction steel True until you kill the Connection WOW !!!
I found that any IBCQuery1.Open Forces IBCConnection1.InTransaction = True
if I do : if IBCConnection1.InTransaction then IBCConnection1.RollBack
this rise an exception : "Can't perform operation on inactive transaction" ???
Stoped on --> VCL.Controls --> procedure TControl.Click;
Exmple 2 :
=======
I can'nt use IBCConnection1 like dbExpress :
IBCConnection1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
IBCConnection1.commit;
except
IBCConnection1.RollBack;
exit;
end;
Because IBCConnection1 steel also, in Transaction after commiting !!!
Can you solve my confusion ?
How can I use a Global Transaction like dbExpress (Starting, Commiting, Rollbacking) that's all ?
(Not talking here, about strategy of modifying manually a DBGrid with its explicit transaction. No, just somme SQL queries).
Thx.
"Delphi XE3 Update2 17.0.4770.56661 win 7 Pro - 32/64 bits"
Hi,
It has been 10 years, i have worked with dbExpress.
I have just baught, last week, the great IBDAC Components for it's very very fast speed ! Thanks to DevArt Team
I have somme difficulties to understand Transactions with IBDAC.
(Sorry for this topic : I could'nt find the solution on your Forum).
So, let see the problem :
1. Transactions with dbExpress are simple :
Just Start one Global Transaction, work with it, then Commit (or RollBack) :
SQLConnection1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
SQLConnection1.commit;
except
SQLConnection1.RollBack;
exit;
end;
After commiting/ Rollbacking, the Connection (SQLConnection1) will not be in Transacion Yet (this is the correct beahvior).
2. With IBDAC the story is different !
Here is what I found in my great confusion :
Put an :
- IBCConnection1, with Autocommit = False
- IBCTransaction1
- IBCQuery1 with Autocommit = False and Transaction = IBCTransaction1
Exmple 1 :
=======
if you start this Explicit Transaction :
IBCTransaction1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
IBCTransaction1.commit;
except
IBCTransaction1.RollBack;
exit;
end;
the IBCConnection1.InTransaction steel True until you kill the Connection WOW !!!
I found that any IBCQuery1.Open Forces IBCConnection1.InTransaction = True
if I do : if IBCConnection1.InTransaction then IBCConnection1.RollBack
this rise an exception : "Can't perform operation on inactive transaction" ???
Stoped on --> VCL.Controls --> procedure TControl.Click;
Exmple 2 :
=======
I can'nt use IBCConnection1 like dbExpress :
IBCConnection1.StartTransaction;
try
_____________________________
Any Select Queries;
Any Execute Queries;
....
_____________________________
IBCConnection1.commit;
except
IBCConnection1.RollBack;
exit;
end;
Because IBCConnection1 steel also, in Transaction after commiting !!!
Can you solve my confusion ?
How can I use a Global Transaction like dbExpress (Starting, Commiting, Rollbacking) that's all ?
(Not talking here, about strategy of modifying manually a DBGrid with its explicit transaction. No, just somme SQL queries).
Thx.