Subject | Re: FB, Delphi 7, IB components and transactions |
---|---|
Author | Adam |
Post date | 2005-01-13T23:28:23Z |
Hi Diego,
It looks like you are still a bit confused about transactions. I gave
you a detailed explanation here:
http://groups.yahoo.com/group/firebird-support/message/53753
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
compliant:
http://cegt201.bradley.edu/projects/proj2003/equiprd/acid.html
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.
Adam
--- In firebird-support@yahoogroups.com, Diego Barros <dbarros@m...>
wrote:
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.
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.
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.
It looks like you are still a bit confused about transactions. I gave
you a detailed explanation here:
http://groups.yahoo.com/group/firebird-support/message/53753
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
compliant:
http://cegt201.bradley.edu/projects/proj2003/equiprd/acid.html
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.
Adam
--- In firebird-support@yahoogroups.com, Diego Barros <dbarros@m...>
wrote:
> Hello,<svein.erling.tysvaer@k...> wrote:
>
> Thanks for the reply, I appreciate it.
>
> On Thursday, January 13, 2005, at 11:07PM, Svein Erling Tysvær
>it
> >> 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?I am writing. Even still, I was running two instances of my test
> >
> >Probably because of transactions...
>
> I neglected to mention that this is a single user application that
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.
>count
> >
> >> 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 Iclick
> >> the Refresh button. I have another button which inserts a newrecord
> >> into the table. So my form has the following components:one
> >>
> >> 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 recordcount
> >> increase. I click Refresh on the other instance of theapplication
> >> and the count does not change.it
> >
> >Well, I haven't seen any commit of the transaction yet, that makes
> >similar to writing a letter to your friend and upon asking, hesays he
> >hasn't received it. Upon asking at the postoffice you discoverthey
> >expect you to actually send the letter.have to commit transactions, do I? Because in that scenario there is
>
> If this is a single instance, single user application, then I don't
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.
>component to
> >> Can this behavior be changed? I changed the transaction
> >> be read-commited, but that did not change the behavior. Maybethis
> >> 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 tryother
> >> components which work differently from a programming point ofview?
> >settings,
> >Well, I think some of it can be changed by the transaction
> >more specifically whether or not you see changes that have beento
> >committed after you started your transaction. But there is no way
> >make visible outside your own transaction anything that hasn'tbeen
> >committed. Take a look at this article: http://www.ibobjectsfrom
> >com/docs/ti_Transactions.ZIP, even though IBObjects is different
> >the Borland components I hope it should give you an idea.the transaction to read-commited, and the AutoStopAction (I think
>
> Playing around with the settings last night I noticed that setting
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