Subject Re: How to find a transaction in the code given TID?
Author dr_john_mp
--- In firebird-support@yahoogroups.com, Krzysztof Koz³owski
<kozlorf@...> wrote:
>
I have got it's ID, now I am
> wondering how can I find this uncommited transaction in the code of my
> application. I am using TIBClientDataSet, TIBQuery and TIBSQL for
> changing the DB content.

I use the following in a timer in applicaions that run for any period
of time. It simply runs round all of the TIBQueryand (in this case)
identifies the oldest transaction number.

I put details in a panel in the status bar and also periodically
(every few mins) write details to a table on the database (that way,
with classic server, I can track the owner of the oldest transaction).
As an altrnative you could obviously put details of all open
TIBQuery's into a visible list/grid. Since this runs under a timer
you can control/limit the overhead (as compared with adding something
which tracks every transaction start/end).


tsql : TIBQuery;

t := 0;
tstr := '';
for i := 0 to LoaderData.ComponentCount -1 do
if LoaderData.Components[i].ClassType = TIBTransaction then
begin
try
tTrans := TIBTransaction(LoaderData.Components[i]);
if tTrans.Intransaction then
begin
j := tTrans.TransactionID;
if (t = 0) or (t > j) then
begin
t := j;
tstr := tTrans.Name;
end;
end;
except

end;
end;