Subject RE: [firebird-support] Re: InterBase, Dephi, BDE and Transactions
Author Helen Borrie
At 04:14 PM 17/11/2004 -0300, you wrote:

>InterBase, Delphi5, BDE and Transactions
>Hello to everybody!
> I´m still trying to use InterBase (really it´s FireBird) with Delphi
> 5 and BDE but I still have a problem with Transactions.
> I really thanks to every one who suggested me things but
> unfortunately nothing worked.

This really has to be your last posting on this subject. This is NOT a
Delphi forum. Several people have warned you about the limitations of
trying to use the BDE with Firebird. That's really where it must end.

Borland runs a large number of Delphi newsgroups on
news:// You might even be able to locate some in Spanish.

Why don't you search around some of the Delphi support sites for some tech
papers on these topics?

You are very welcome to raise topics related to Firebird and even
InterBase; but please take your Delphi Basics questions elsewhere. I'm
asking you this as moderator of this list.


> I tried starting a transaction with another Session component but,
> as I supposed, it didn´t worked because each transaction is independent
> of the other (the implicit one made by the BDE and the one I started in
> another Session).

Of course. A separate session means a separate session between the
application and the database. You can't escape from that model using the
BDE. Beneath each session instance a sepeare connection-embedded
transaction combination.

> I tried using CachedUpdates but unfortunately, even in this case,
> the BDE makes an internal transaction and the problem is the same. I
> write here my code in case anybody knows I´m doing something wrong.

What you are doing wrong is assuming that you can access the single and
only transaction that the BDE allows you, as a transaction. YOU
CAN'T. The BDE model does not give you access to the transaction, except
through some of its properties and methods that are surface in the
TDatabase. There is NO WAY AROUND THIS. If there were, the world would
not have needed IB Objects, FreeIBPlus, etc.

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

Only one transaction is allowed. The Open call starts this transaction if
it is not already started.

>{ DataBaseGeneral.StartTransaction;

This causes an exception which is swallowed. The transaction is already

> Edit;

Edit should be called after Open (or, preferably, on demand, by the user.)


This is wrong use of the Text property of TField. You are likely to bump
into problems if you use it this way --- but this is NOT a Delphi forum, so
I'll let you find out about this for yourself.

> Post;
>{ DataBaseGeneral.RollBack;}
> DataBaseGeneral.ApplyUpdates([TablaDeProvincias]);

No. ApplyUpdates ***replaces*** Post when you use cached updates.

> Close;

No. You call the Commit method of the TDatabase now, followed by the
CommitUpdates method of the dataset, to reset the cache.

> DataBaseGeneral.Connected:=False;

> end;
>At the line "DataBaseGeneral.ApplyUpdates([TablaDeProvincias]);" I get the
>error message "Nested transactions not supported".

Get rid of all the extraneous references to transactions and it will be
OK. At the moment your code is causing a merry dance for the one and only

> I had another idea: starting a transaction directly with an SQL
> instruction. But I couldn´t do it.


That ability is not available in DSQL (which is what your applicatiion has
to do). Delphi components use the structures and calls of the API. You
don't have to know the hidden details of that, you only have to know what
you are doing and what are the limitations of this BDE data access layer.