Subject Re: [firebird-support] Re: InterBase, Dephi, BDE and Transactions
Author Helen Borrie
At 05:18 AM 16/11/2004 +0000, you wrote:


>Helen (and the others who answered this question):
>
>You say in my code I´m doing this:
>
>start transaction
> prepare query if not prepared
> run query (i.e. call Open)
> start another transaction
> do some stuff
> post changes
> .....
>
>I see your
>"start another transaction"
>
>is my
>"DataBaseGeneral.StartTransaction;"
>(after the Open)
>
>But I don´t see where is your first
>"start transaction"
>in my code.

When you call Open on a dataset, Delphi starts a transaction if one is not
already started -- you can't Open a dataset if there is no transaction!!


>If I debug and see DataBaseGeneral.InTransaction before the
>DataBaseGeneral.StartTransaction, it is False. So, there is no
>Transaction started before the "DataBaseGeneral.StartTransaction;"
>instruction.
>
>Even in the Help of Delphi, it is explained that I have to do things
>the way I´m doing. That´s why I don´t understand the mistake.

Not in my Delphi Help.


>¿When does the first transaction you mention starts?

See above.
To repeat the point ----

> > Your code:

[snip]

> > > TablaDeProvincias:=TTable.Create(nil);
> > > with TablaDeProvincias do
> > > begin
> > > TableName:='Provinc';
> > > IndexFieldNames:='NOMBRE';
> > > DataBaseName:=DataBaseGeneral.DataBaseName;

Next, if Delphi gets an Open call and there is no transaction, it starts
one. This is known as "Delphi's implicit transaction model". It doesn't
start transactions in RDBMSs that don't have them. :-)

To do this explicitly, you might have written code something like the
following:

if DataBaseGeneral.InTransaction then
begin
DataBaseGeneral.Commit;
DataBaseGeneral.StartTransaction;


> > > Open;
> > >
> > > DataBaseGeneral.StartTransaction;

and by now, the transaction is started, so you can't go a head and start
another one while the current one is neither committed nor rolled
back. Delphi thinks you are trying to request a nested transaction and it
whines at you.

./hb