4D S.A. Copyright 2001

4D Open for Java development can perform complex updates, including those involving multiple tables, while still maintaining data integrity. To provide this functionality, 4D Open for Java includes routines for starting, validating, and cancelling transactions.

Transactions are a series of related data modifications that are made to a database within a process. The operations performed within a transaction are not saved permanently to a database until the transaction has been validated. If the transaction has not completed, either because it is cancelled or because of some outside event, the modifications are not saved.

Transaction Example


A good example of the need for transactions is a banking application. In the application, you want to ensure that when transferring money between accounts, the debit to the first account and the credit to the second account both take place. For this reason, the debit and the credit action should occur within the same transaction. If either the debit or credit action fails, the entire operation will be cancelled.

A transaction can be started with the StartTransaction method. During a transaction, all changes that are made to the data of a database within a process are stored locally in a temporary buffer. If the transaction is accepted with ValidateTransaction, the changes are saved permanently. If the transaction is cancelled with CancelTransaction, any changes made to the database are not saved.

Note: Since transactions deal with temporary record addresses, the current selection of each table will be empty after a transaction is validated or cancelled. For the same reason, after a transaction is validated or cancelled, a named selection created before or during the transaction may contain incorrect record addresses. For instance, a named selection may contain the address of a deleted record or the temporary address of a record added during the transaction.


4D S.A. Copyright 2001