transaction

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
calou
Posts: 116
Joined: Tue 27 May 2008 12:46

transaction

Post by calou » Mon 15 Mar 2010 21:12

Hello,

In this example (autocommit is false)

Code: Select all

for i:=0 to 20 do
begin
  ibcquery.sql.text:='select * from MyTable where nom=:nom';
  ibcquery.fieldbyname('nom').asstring=inttostr(i);
  ibcquery.open;
  something...
end;
ibcquery.transaction.rollback;
if i have understood correctly the behavior of ibccquery, when i call .open a transaction is automatically starded. But are all the transactions in the for loop have the same number?
I ask this question because i am not sure that when i call the .rollback i close all the transactions that have been opened in the for loop or if i have to call the .rollback after the "something"

Thanks for explanations

Regards

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 17 Mar 2010 11:08

Hello,

In your example all loop iterations will be executed in the same transaction. And rollback in the end will cancel all you actions in the loop (because AutoCommit = false).

If you want to execute each loop iteration in a new transaction you should create an array of transactions and you should assign ibcquery.Transaction := TransactionArray in each iteration of the loop. Then after loop you can commit or rollback each transaction separately.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 17 Mar 2010 15:43

Thank you very much for this very clear explanations

Regards

Post Reply