Subject | RE: [IBO] Transaction management |
---|---|
Author | Support List |
Post date | 2011-11-10T21:25:18Z |
> I have some questions about transaction management. Suppose I haveThis is correct.
> TIB_Connection (con1) and a TIB_Transaction (tran1). I set it up such
> that con1.DefaultTransaction := tran1. I then add a TIBOQuery (qry1) and
> set qry1.IB_Connection := con1 and qry1.IB_Transaction := tran1 and
> qry1.CommitAction := caFetchAll and qry1.FetchWholeRows := True. I then
> add a TDBGrid (grid1) and set the datasource to qry1 via a TDataSource
> component.
>
> In my OnShow handler I do this:
>
> con1.Connect;
> trans1.StartTransaction;
> qry1.Open;
> trans1.Commit;
>
> I would expect this to start a transaction, read all rows into qry1 and
> commit. I would expect there to be no active transactions at this point.
However, watch out for the dataset's CommitAction property.
> However, con1.TransactionCount shows 2 transactions in total.This is the internal transaction IBO uses to get info from the metadata.
> con1.StartedTransactionCount shows 1 active transaction. And it willThis is taken care of automatically due to the Timeout properties. IBO
> stay active for approx 1 minute and then I can see a second commit in the
> SQL monitor and StartedTransactionCount goes to zero.
manages its internal transactions in such a way that you get them when you
need them and then they stick around for a bit and go away when they've
timed out. This makes it so your server isn't bogged down with too many
transactions and all the network chatter of starting and stopping them for
each little metadata action taken.
> How can I be certain that there are no active transactions?You just need to worry about the ones you work with. There is a way you can
force them all closed if that's really necessary. You can scan through the
list of Transactions for a connection and commit them all.
HTH,
Jason