4 Database Manipulation
The DBROLLBACK statement provides a rollback operation, that reverts pending database operations. After a successful (top level) commit, the transaction is guaranteed to be present in the data base, even in case of a server crash. So it can be guaranteed, that either all dependend operations are saved entirely or no modifications are done.
Pending data base changes are neither visible to other users nor can they be changed concurrently. All pending data base records are locked automatically by the data base server and any attempt to modify them will cause the concurrent task to become paused.
Transactions can be nested. The DBCOMMIT or DBROLLBACK statements usually operate on the last (sub-) transaction. Data base modifications are not stored permanently in the data base, until a top level DBCOMMIT is executed. The DBROLLBACK statement can be used to undo all pending modifications until a specific checkpoint.
Please note, that the transaction handling statements do not operate on a particular data base. Instead they operate on all data bases at once. A pending commit or rollback is even performed after closing the data base. In case a data base server connection is lost (for example, because the server has been killed), all pending modifications on all data bases are automatically reverted.
Each transaction gets a unique is assigned with the DBBEGIN statement and a name of this transaction can be defined to address this transaction later on.
Up to 20 transactions can be nested. Each DBBEGIN statement returns a unique (process specific) transaction id, which can be used with the DBROLLBACK statement to revert all modifications until this state.
DBBEGIN (comment, mode, status(*))
The parameters are:
Array Element | Value | Description |
---|---|---|
1 | 0 | CW. |
2 | 0 | Transaction ID |
3 | 0 | Transaction Level |
DBCOMMIT (mode, status(*))
The parameters are:
commit all transactions
2
commit top level transaction
Array Element | Value | Description |
---|---|---|
1 | 0 | CW. |
DBROLLBACK (ID, mode, status(*))
The parameters are:
Rollback current (sub-)transaction
2
Rollback given transaction
3
Rollback top level transaction
Array Element | Value | Description |
---|---|---|
1 | 0 | CW. |
3 | 0 | Transaction Level |