Rollback issue when using two queries with cached updates

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ali.Mustapha
Posts: 7
Joined: Fri 02 May 2014 13:37

Rollback issue when using two queries with cached updates

Post by Ali.Mustapha » Wed 27 Jul 2016 14:55

hi,
I use Unidac 4.6.11 in Delphi XE2 , I have two Queries which are in cached updates mode , also both of them have same update transaction (UniTransaction1), this is the code that I use in the save button :

UniTransaction1.StartTransaction;
try
Query2.applyupdates;
Query1.applyupdates;
UniTransaction1.Commit;
except
UniTransaction1.RollBack;
end;

if one of the queries fail , both of them must be rollbacked , but the problem is that even if one of them fails the other saves normally.
I need to know where is the problem in my code. and if you have another approach please advice me.
thanks in advance.

Ali.Mustapha
Posts: 7
Joined: Fri 02 May 2014 13:37

Re: Rollback issue when using two queries with cached updates

Post by Ali.Mustapha » Wed 27 Jul 2016 23:20

i just found the solution with setting the auto commit of the queries to False ,
I just have another question is there any need to disable the auto commit of the uni connection or just for the needed query ???

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

Re: Rollback issue when using two queries with cached updates

Post by ViktorV » Thu 28 Jul 2016 08:54

Please specify the database you are working with.

Ali.Mustapha
Posts: 7
Joined: Fri 02 May 2014 13:37

Re: Rollback issue when using two queries with cached updates

Post by Ali.Mustapha » Thu 28 Jul 2016 21:31

interbase

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

Re: Rollback issue when using two queries with cached updates

Post by ViktorV » Fri 29 Jul 2016 13:13

You have found a correct solution for this case by setting the TUniQuery.AutoCommit property to False.
The TIBCConnection.AutoCommit property has higher priority than the AutoCommit property of datasets (TIBCQuery, TIBCTable).
If the TIBCConnection.AutoCommit property is set to False, all transactions can be committed only explicitly (despite the AutoCommit property value of a dataset).

Post Reply