Page 1 of 1

Problem with Rollback Transaction

Posted: Wed 08 Aug 2018 13:04
by ArizmendiTeam
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)

Re: Problem with Rollback Transaction

Posted: Wed 08 Aug 2018 19:05
by ArizmendiTeam
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)

Re: Problem with Rollback Transaction

Posted: Thu 09 Aug 2018 12:12
by ViktorV
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;

Re: Problem with Rollback Transaction

Posted: Thu 09 Aug 2018 12:47
by ArizmendiTeam
Hi ViktorV:
It works excellent!!!!

Thanks a lot!!!

Angélica ( Arizmendi Team)

Re: Problem with Rollback Transaction

Posted: Fri 10 Aug 2018 08:28
by ViktorV
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.