RDOHELP72.HLB  —  ROLLBACK  Example
    Roll back changes made during a transaction with a COBOL program:

    GET-ID-NUMBER.
          DISPLAY "Enter employee ID number:  "
             WITH NO ADVANCING.
          ACCEPT EMPLOYEE-ID.
    CHANGE-SALARY.
          DISPLAY "Enter new salary amount:  "
             WITH NO ADVANCING.
          ACCEPT SALARY-AMOUNT.

    &RDB&   START_TRANSACTION READ_WRITE
    &RDB&    FOR S IN SALARY_HISTORY WITH
    &RDB&       E.EMPLOYEE-ID = EMPLOYEE-ID
    &RDB&          MODIFY USING
    &RDB&             S.SALARY-AMOUNT = SALARY-AMOUNT
    &RDB&          END-MODIFY
    &RDB&   END-FOR

          DISPLAY EMPLOYEE-ID, SALARY-AMOUNT.
          DISPLAY "Is this figure correct? [Y or N]  "
             WITH NO ADVANCING.
          ACCEPT ANSWER.
          IF ANSWER = "Y" THEN
    &RDB&   COMMIT
          ELSE
    &RDB&   ROLLBACK
            DISPLAY "Please enter the new salary amount again."
            GO TO CHANGE-SALARY.
Close Help