Subject Re: [firebird-support] Transactions and dbExpress
Author Martijn Tonies
Hello Christian,

> I read in the "Firebird Book" about transactions and it looks like
> certain fine tuning is not possible with dbExpress/Firebird. So here
> are my remaining questions:
>
> - Is it correct, that transactions should be as short as possible? So
> best is just a transaction for each statement? (except for bulk
> insert/update)
>
> - Should I use READONLY READCOMMITTED transactions for SELECT
> statements where ever possible? (because of OIT/OAT)

It depends on your requirements. For "simple" gui applications, I use
read-committed transaction isolation. But for a report, for example,
one would use the snapshot isolation.

> - I think IsolationLevel xilREPEATABLEREAD corresponds to SNAPSHOT in
> Firebird?
>
> - How can I set the transaction to READONLY ?
>
> - Where and whant kind of transaction is started, if I don't call
> StartTransaction? With a SELECT Statement ? With INSERT/UPDATE/DELETE
> Statement?

Transation management in a dbExpress driver is a bit weird -- Borland
doesn't
tell you anything on how to do this.

Currently, any SELECT will use the trans-isolation as passed to the driver
via
the parameter in TSQLConnection.

Any INSERT/etc will use auto-commit by default, unless a transaction has
been
started.

Any new statement will use the last started transaction, unless you
explicitly tell
it to use anothe.

> When I look at the code in SqlExpr.pas, the property InTransaction
> doesn't reflect the real value of the transaction. I suppose, this is
> handled in the dbExpress driver (Upscene), so Martijn will know the
> details here? Did I miss any documentation about that?

Well, the last version of our dbExpress driver comes with a unit
"upDBX_FBConst.pas"
that allows you to generate custom transaction isolations - read only etc
... Here's
the constants:

{ Transaction Access modes }
TR_AM_READ : LongWord = $00000001; { isc_tpb_read, read
only }
TR_AM_WRITE : LongWord = $00000002; { isc_tpb_write,
read/write }
{ Transaction Isolation levels }
TR_ISO_CONCURRENCY : LongWord = $00000004; { isc_tpb_concurrency }
TR_ISO_CONSISTENCY : LongWord = $00000008; { isc_tpb_consistency }
TR_ISO_READ_COMMITTED : LongWord = $00000010; {
isc_tpb_read_committed }
TR_ISO_REC_VERSION : LongWord = $00000020; { isc_tpb_rec_version }
TR_ISO_REC_NO_VERSION : LongWord = $00000040; {
isc_tpb_rec_no_version }
{ Transaction Lock Resolution }
TR_LOCK_WAIT : LongWord = $00000080; { isc_tpb_wait }
TR_LOCK_NO_WAIT : LongWord = $00000100; { isc_tpb_no_wait }

This might help as well.

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com