Subject Re: [firebird-support] Delphi and Transactions
Author Ann W. Harrison
At 05:21 PM 12/2/2004, Diego Barros wrote:

>Hi all,
>
>I have a couple of questions regarding transactions and FB. When I do
>anything in a Delphi/FB application, I always have to have a
>StartTransaction and Commit/Rollback?

You don't need a start transaction unless you want to start something
other than the default transaction. If you issue a SQL statement without
an active transaction the system starts a transaction for you. Unless
you commit, the system will rollback your changes when you disconnect
from the database.

>Even for a SELECT statement?

Yes. Select statements are part of transactions.

> I noticed that when I was inserting a record in the database, it was
> being done correctly (I was using transactions), but when I did a select
> it was not being returned.

That can happen if you haven't committed your inserts and the select
is done in a different transaction - say from a different connection.

>I've seen some code samples on the newsgroups which didn't have a
>StartTransaction call, but just a Commit after executing some SQL or
>stored proc. Is this OK to do?

In purist circles, it's considered uncouth, but it works.

> Or must I always use the start, commit/rollback combination? Do I need
> transactions when using a stored procedure component and calling
> ExecProc() too?

Yes and the transaction must be started and ended by the client.

Regards,


Ann