3.8.1. The Read-only Transaction
The trRead
read transaction is started when the dataset form is displayed (the OnActivate
event) and is ended when the form is closed. READ COMMITTED
isolation level (Options.Isolation = xiReadCommitted
) is usually used to show data in grids because it allows the transaction to see changes committed in the database by other users by just repeating queries (rereading data) without the transaction being restarted.
Since this transaction is used only to read data, we set the Options.ReadOnly
property to True. Thus, our transaction will have the following parameters: read read_committed rec_version
.
Why? A transaction with exactly these parameters can remain open in Firebird as long as necessary (days, weeks, months) without locking other transactions or affecting the accumulation of garbage in the database because, with these parameters, a transaction is started on the server as committed. |
We set the property Options.DisconnectAction
to xdCommit
, which perfectly fits a read-only transaction. Finally, the read transaction will have the following properties:
Options.AutoStart = False
Options.AutoCommit = False
Options.AutoStop = False
Options.DisconnectAction = xdCommit
Options.Isolations = xiReadCommitted
Options.ReadOnly = True
Although we do not discuss reporting in this manual, be aware that you should not use such a transaction for reports, especially if they use several queries in sequence. A transaction with |