Subject Re: FB, Delphi 7, IB components and transactions
Author Adam
Hi Diego,

It looks like you are still a bit confused about transactions. I gave
you a detailed explanation here:

Perhaps I can simplify a bit.

Until you commit your transaction, it is just as if nothing was
changed. Think of commit like saving your work to disk. Other
transactions can only look at what is on the disk. (This is not how
it actually works, but it is a helpful way of thinking about
transaction isolation.

Read this page to understand isolation a bit more. Firebird is ACI

Whether that transaction is running inside the same executable, or
from a different executable on the same machine, or from an
executable on another machine, it is the same thing. Firebird will
not tell another transaction about changes you make until you commit
the transaction.

By the way, your crash probably stems from commit ending the
transaction, and you not starting another one. If you want to
instantly start another, then you can use commit retaining.
Otherwise, remember that a query can only be run if its transaction
has been started.

Good luck.

--- In, Diego Barros <dbarros@m...>
> Hello,
> Thanks for the reply, I appreciate it.
> On Thursday, January 13, 2005, at 11:07PM, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
> >> 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
> >> in another running program?
> >
> >Probably because of transactions...
> I neglected to mention that this is a single user application that
I am writing. Even still, I was running two instances of my test
application to try and get a better idea as to what happens when
dealing with transactions and which application can see what when the
other makes a change to the database.
> >
> >> I have a small test application with a query which selects a
> >> of records from a table. On a form I show this number when I
> >> the Refresh button. I have another button which inserts a new
> >> 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
> >> instance of the program, click refresh and I see the record
> >> increase. I click Refresh on the other instance of the
> >> and the count does not change.
> >
> >Well, I haven't seen any commit of the transaction yet, that makes
> >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
> >expect you to actually send the letter.
> If this is a single instance, single user application, then I don't
have to commit transactions, do I? Because in that scenario there is
no recipient of the letter. There is no other user, client, or
application which will want to see any changes I make to the
database. But, for a multi-user application, then what you say is
true and is required when coding against IB/FB.
> >> Can this behavior be changed? I changed the transaction
component to
> >> be read-commited, but that did not change the behavior. Maybe
> >> is all about a different mindset and how one works with IB/FB?
> >> there any articles which talk about this? Maybe I need to try
> >> components which work differently from a programming point of
> >
> >Well, I think some of it can be changed by the transaction
> >more specifically whether or not you see changes that have been
> >committed after you started your transaction. But there is no way
> >make visible outside your own transaction anything that hasn't
> >committed. Take a look at this article: http://www.ibobjects
> >com/docs/ti_Transactions.ZIP, even though IBObjects is different
> >the Borland components I hope it should give you an idea.
> Playing around with the settings last night I noticed that setting
the transaction to read-commited, and the AutoStopAction (I think
that's the name, I'm not at my machine now) to saCommit, resulted in
the other instance being able to see the changes the first one made
to the database. This was two instances of the application running at
the same time, hence using different transactions.
> Cheers,
> Diego