In this section: |
How to: |
Reference: |
The ROLLBACK command processes a logical transaction. A logical transaction is a group of data source changes that are treated as one. The ROLLBACK command cancels prior UPDATE, INCLUDE, and DELETE operations that have not yet been committed to the data source using the COMMIT command.
The syntax of the ROLLBACK command is
ROLLBACK [;]
where:
Terminates the command. Although the semicolon is optional, you should include it to allow for flexible syntax and better processing. For more information about the benefits of including the semicolon, see Terminating a Command's Syntax.
This example shows part of a procedure where an employee ID needs to be changed. Because Emp_ID is a key, it cannot be changed. To accomplish this, it is necessary to collect the existing field values, make the necessary changes, delete the employee from the data source, and add a new segment instance.
The following shows partial code where the existing instance is deleted and a new one is added. If for some reason the INCLUDE does not work, the DELETE should not occur.
CASE Chngempid DELETE Emp_ID; IF FocError NE 0 PERFORM DeleteError; INCLUDE Emp_ID Bank_Name Dat_Inc Type Pay_Date Ded_Code; IF FocError NE 0 PERFORM Undo; ENDCASE
CASE Undo ROLLBACK; ENDCASE
When an application accesses more than one DBMS (for example, DB2 and Teradata), ROLLBACK is treated as a broadcast rollback. There is no coordination between the different types of data sources, therefore the ROLLBACK might succeed against one type of data source but fail against another.