Transaction Problems
Posted: Fri 04 Apr 2014 21:22
Hello all,
I have bought UniDAC a few days ago and I am migrating a FibPlus aplication.
As I am working with Firebird I am using two transactions, a ReadOnly one for the Transaction Property and a ReadWrite one for the UpdateTransaction Property of a TUniQuery.
I've set the RefreshOptions as [roAfterInsert,roAfterUpdate,roBeforeEdit] so I believe that after a Post the data will be updated correctly.
But then I have a slight problem, as I am working with two transactions I do a commit on the UpdateTransaction and a CommitRetaining on the Transaction, but how can I detect that they are InTransaction? The Intransaction Property exists only in the UniConnection object, not in the UniTransaction Object. So when I try something like (as a simple Example)
(I have set the RW Transaction as the Default Transaction for the UniConnection).
Function DoCommit : Boolean
var
OkTrans : boolean;
begin
OkTrans := True;
if DbConnection.InTransaction then
try
TrGrv.Commit;
except
TrGrv.Rollback;
OkTrans := False;
end;
if TrRO.InTransaction then
try
TrRO.CommitRetaining;
except
TrRO.RollbackRetaining;
OkTrans := False;
end;
Result := OkTrans;
end;
the first transaction condition can be detected and will work properly, the second is not possible. I saw in the sources that there is a DetectInTransaction function that is protected in the UniTransaction, why is this so? In situations when one is working with double transactions it is necessary to be able to detect if the transaction is InTransation so the code can work properly.
How can this be done?
Thank you
Andrew S. Vaz
I have bought UniDAC a few days ago and I am migrating a FibPlus aplication.
As I am working with Firebird I am using two transactions, a ReadOnly one for the Transaction Property and a ReadWrite one for the UpdateTransaction Property of a TUniQuery.
I've set the RefreshOptions as [roAfterInsert,roAfterUpdate,roBeforeEdit] so I believe that after a Post the data will be updated correctly.
But then I have a slight problem, as I am working with two transactions I do a commit on the UpdateTransaction and a CommitRetaining on the Transaction, but how can I detect that they are InTransaction? The Intransaction Property exists only in the UniConnection object, not in the UniTransaction Object. So when I try something like (as a simple Example)
(I have set the RW Transaction as the Default Transaction for the UniConnection).
Function DoCommit : Boolean
var
OkTrans : boolean;
begin
OkTrans := True;
if DbConnection.InTransaction then
try
TrGrv.Commit;
except
TrGrv.Rollback;
OkTrans := False;
end;
if TrRO.InTransaction then
try
TrRO.CommitRetaining;
except
TrRO.RollbackRetaining;
OkTrans := False;
end;
Result := OkTrans;
end;
the first transaction condition can be detected and will work properly, the second is not possible. I saw in the sources that there is a DetectInTransaction function that is protected in the UniTransaction, why is this so? In situations when one is working with double transactions it is necessary to be able to detect if the transaction is InTransation so the code can work properly.
How can this be done?
Thank you
Andrew S. Vaz