Subject Re: [IBO] Strange behaviour
Author Helen Borrie
At 03:39 PM 8/03/2003 +0100, you wrote:
>hello all,
>I'm starting to experiment with IB Objects and I have noticed a
>strange behaviour.
>I have a Delphi form with the following components:
>1 TIB_SearchBar
>1 TIB_NavigationBar
>1 TIB_TransactionBar (Commit and Rollback visible)
>1 TIB_UpdateBar
>1 TIB_Transaction
>1 TIB_DataSource
>1 TIB_Query
>1 TIB_SearchPanel
>1 TIB_Grid
>3 TIB_Edit
>1 TIB_Date
>1 TIB_CheckBox
>The transaction bar and the query are bound to the TIB_Transaction on
>the form that is bound to the main TIB_Connection that lives on a
>separate data module.
>The SELECT statement is very simple: SELECT * FROM TableName. The
>query is opened in the form's OnActivate handler.
>Well, when the form becomes visible with the query already opened, the
>two buttons in the transaction bar are enabled,

This is because the transaction was started in order to perform the SELECT
query. Everything in Fb/IB happens in a transaction.

>but if I click on any of the two nothing happens, apart that the busy
>cursor appears briefly.

>If I wait about two-three minutes, the buttons become grayed; I
>suppose that this means that a transaction has been ended somehow, but
>*what transaction* if I haven't performed any operation on the table

A transaction is ended by performing a Rollback or Commit. The query
finished fetching all of the rows into the before the commit, hence the
delay. If the transaction had AutoCommit True, then, after committing, the
transaction would be restarted using the same cursors.

>After the buttons has become grayed, if I insert/edit/delete a
>row, the behaviour of the transaction bar is now normal.

Calling any of these methods will cause IBO to check whether a transaction
is started and, if not, it will start it.

>Furthermore, I have put a control in the OnCloseQuery of the form that
>alerts me if the transaction is still active before closing the form.
>Ok, in the above mentioned status (form opened, buttons enabled) I can
>close the form without any warning, meaning that the transaction is
>not active.

There are a number of possibilities here, depending on what method you call
when your test button is clicked, and what state the dataset is in at the
moment you call it. As a general rule, if the form owns the transaction,
then it will roll back any posted but uncommitted work before closing the form.

>So is it possible that there is a bug in the transaction bar?

Not on the evidence provided here. A more useful way to monitor what is
going on is to use an IB_MonitorDialog.