Problem with Rollback Transaction

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ArizmendiTeam
Posts: 10
Joined: Fri 13 Jul 2018 18:36

Problem with Rollback Transaction

Post by ArizmendiTeam » Wed 08 Aug 2018 13:04

Hi Viktor!!
We 've a probleme with Rollback Transaction. We ´ve made a test case. ( one table, one transaction, one connection)
Embarcadero: Delphi Tokyo ( VCL)
var
vQuery : TIBCQuery;
tranUpdatetc: TIBCTransaction;

begin
IBCtable1.AutoCommit := false;

tranUpdatetc := TIBCTransaction.Create(IBCConnection1);
tranUpdatetc.DefaultConnection:=IBCConnection1;
tranUpdatetc.StartTransaction;

try
vQuery := TIBCQuery.Create(nil);
vQuery.AutoCommit:= false;
vQuery.UpdateTransaction:=tranUpdatetc;
vQuery.Connection := IBCConnection1;
vQuery.Sql.Add( 'UPDATE ELFORMULARIOS SET GENERADO = ''N''');
vQuery.ExecSQL;

if tranUpdatetc.Active = true then
Begin
tranUpdatetc.Rollback; ( we´re testing rollback, but it doesn't work)
End;

except
tranUpdatetc.Commit;
vQuery.Free;
tranUpdatetc.Free;
end;
end;
Can you help us? what´s happens?

Thanks in advanced

Angélica ( Arizmendi Team)

ArizmendiTeam
Posts: 10
Joined: Fri 13 Jul 2018 18:36

Re: Problem with Rollback Transaction

Post by ArizmendiTeam » Wed 08 Aug 2018 19:05

Hi Viktor:
For us, the Connection must not have a default transaction, 'cause we´re using a lot transactions and one connecction.

Thanks in advance.

Angélica ( Arizmendi Team)

ViktorV
Devart Team
Posts: 2387
Joined: Wed 30 Jul 2014 07:16

Re: Problem with Rollback Transaction

Post by ViktorV » Thu 09 Aug 2018 12:12

Note, that upon execution of the TIBCQuery.ExecSQL method, a transaction defined in the TIBCQuery.Transaction property, and not in the TIBCQuery.UpdateTransaction property, is used.
To solve your task in your sample, you can replace the code line

Code: Select all

vQuery.UpdateTransaction:=tranUpdatetc;
with

Code: Select all

vQuery.Transaction := tranUpdatetc;

ArizmendiTeam
Posts: 10
Joined: Fri 13 Jul 2018 18:36

Re: Problem with Rollback Transaction

Post by ArizmendiTeam » Thu 09 Aug 2018 12:47

Hi ViktorV:
It works excellent!!!!

Thanks a lot!!!

Angélica ( Arizmendi Team)

ViktorV
Devart Team
Posts: 2387
Joined: Wed 30 Jul 2014 07:16

Re: Problem with Rollback Transaction

Post by ViktorV » Fri 10 Aug 2018 08:28

It is good to see that the problem has been solved.
Feel free to contact us if you have any further questions about our products.

Post Reply