Subject Re: FB, Delphi 7, IB components and transactions
Author Svein Erling Tysvær
> Hi all,

Hi Diego!

> I am a newbie when it comes to transactions, so please excuse my
> ignorance when it comes to transactions.

Well, almost everything within Firebird happens within a transaction,
so you have to learn a bit about them.

> I am using FB 1.5.2, with Delphi 7 and the IB components. My
> question is, why when I insert a record into a table don't I see it
> in another running program?

Probably because of transactions...

> I have a small test application with a query which selects a count
> of records from a table. On a form I show this number when I click
> the Refresh button. I have another button which inserts a new record
> into the table. So my form has the following components:
>
> IBQuery1 - which does a SELECT COUNT(*) on the table
> IBQuery2 - which inserts a record
> IBDatabase - used by both queries
> IBTransaction - used by the IBQuery1, IBQuery2 and IBDatabase
> components
>
> When I click the Refresh button I execute the following code:
>
> IBQuery1.Close();
> IBQuery1.Open();
>
> When I click the Insert button I execute the following code:
>
> IBQuery2.ExecSQL;
>
> I then run two copies of this test program. I insert a record in one
> instance of the program, click refresh and I see the record count
> increase. I click Refresh on the other instance of the application
> and the count does not change.

Well, I haven't seen any commit of the transaction yet, that makes it
similar to writing a letter to your friend and upon asking, he says he
hasn't received it. Upon asking at the postoffice you discover they
expect you to actually send the letter.

After doing this, your friend still says he hasn't received it. Asking
at his local post office, he discovers that he actually has to look at
his own mailbox, it is not enough that he once looked at it a few
months back. Checking his mailbox again, he finds your letter.

> Can this behavior be changed? I changed the transaction component to
> be read-commited, but that did not change the behavior. Maybe this
> is all about a different mindset and how one works with IB/FB? Are
> there any articles which talk about this? Maybe I need to try other
> components which work differently from a programming point of view?

Well, I think some of it can be changed by the transaction settings,
more specifically whether or not you see changes that have been
committed after you started your transaction. But there is no way to
make visible outside your own transaction anything that hasn't been
committed. Take a look at this article: http://www.ibobjects
com/docs/ti_Transactions.ZIP, even though IBObjects is different from
the Borland components I hope it should give you an idea.

Good luck in learning transactions,
Set