Transaction Handling
Transaction Handling is a feature that ensures that updates defined as belonging within a transaction are maintained together as a set. If, for any reason, the transaction is not completed, the remaining updates are deleted from the database to maintain its consistency. This feature also suspends the release of item locks set within transactions to preserve the integrity of the database.
Note
Your system must be configured to support Transaction Handling. Refer to Resilience for details.
Transaction Logging is an feature that saves all updates (or updates to selected accounts and/or files) to disk.
What is a Transaction?
A transaction is a set of related updates. These are defined by the applications programmer by means of 'start', 'end' and 'abort' transaction commands (or statements). These are available within ALL, DataBasic, RPL, or from a Proc as TCL commands.
These transaction boundary commands can be used to update existing application code to incorporate transactions. This might, in some cases, require some restructuring of the application in order to collect related updates together so that they are performed in sequence and can, therefore, be defined as a transaction. When designing applications to incorporate transactions, the definition of transactions should be an integral part of the design.
Proc Interface to Transactions
It is important that the concept of transactions is understood and the particular application considered in detail before modifying or writing an application.
A transaction is defined by issuing a command to start the transaction followed by a command to end the transaction. Updates between the start and end of the transaction belong within that transaction.
The start command can be issued from TCL, DataBasic, ALL, or from Proc as a TCL command. The end command for the same transaction can then be issued from any of these (not necessarily the one from which the start was issued).
An abort command can be issued which will undo all of the updates performed since the transaction start. The abort can be issued from TCL, DataBasic, ALL, or from Proc as a TCL command.
You can also display the transaction status of your port. This query can be issued from TCL, DataBasic, ALL, or from Proc as a TCL command.
Transactions in general should be made as small as possible to give maximum resilience to the system (minimise the work lost in the event of a system failure) and minimum impact on performance. Performance can be affected by large transactions because during a transaction the release of item locks is suspended. This might prevent other transactions from proceeding.
If a port is logged off remotely by either PH-KILL or LOGOFF and the port is inside a transaction, the transaction is aborted.
Item Locking
This is a mechanism to prevent multiple processes attempting to access the same item at the same time. Transaction Handling suspends the release of item locks set within transactions to prevent interaction between transactions causing corruption of the database. To prevent deadly embraces, every application should set item locks in the same sequence.
Transaction Handling Commands
The following TCL commands are used from within Proc to start, end, abort, and display the status of transactions.
TRANSTARTTRANSTART can be executed as a TCL command from within Proc to mark the start of a transaction.
TRANSENDTRANSEND can be executed as a TCL command from within Proc to mark the end of a transaction.
TRANSABORTTRANSABORT can be executed as a TCL command from within Proc to undo all the item updates performed by the current transaction.
TRANSQUERYTRANSQUERY can be executed as a TCL command from within Proc to display the transaction status of the current port.