ROLLBACK Statement

The ROLLBACK TRANSACTION verb causes a transaction to be rolled back or canceled.

General Format

ROLLBACK TRANSACTION

General Rules

The following rules describe how transaction management operates with Vision and relative files. For other file systems linked with the runtime, each system's native mechanism for transaction management is invoked. See the Acucorp interface document for the specific file system for more details.

  1. ROLLBACK locks the log file, checks its integrity, then writes a ROLLBACK notation to the log file and unlocks it.
  2. When ROLLBACK is enabled in the FILE-CONTROL entry for a file, the record and file locking rules are extended for that file. Every record updated as part of a transaction is locked until that transaction is committed or rolled back. The ROLLBACK verb removes these locks. Record locks applied when reading the file are also kept until the end of the transaction.
  3. During a transaction involving Vision or relative files, a CLOSE of a file that is locked, or that has locked or deleted records, is postponed until the transaction is committed or rolled back. If the same physical file is opened again within the transaction, even if the program is using a different logical file (different SELECT), the postponed CLOSE is canceled. Note that the mode of the original OPEN is retained. (For example, if the file were originally OPEN I-O, and if the CLOSE were canceled, then an OPEN OUTPUT on the same file within the same transaction would not recreate the file.) When the second OPEN is encountered, the file position is reset to the beginning so that a READ NEXT would read the first file in the record. CLOSE is handled in this special way so that record locks are held—these locks are necessary for rollback.
  4. If the runtime system is killed by the user or encounters a fatal error prior to completing a transaction, an automatic rollback occurs.
  5. Unless the LOGGING configuration variable is set to 0, file operations that occur in transactions are logged and recoverable regardless of whether the files have rollback capability.
  6. Temporary files used for rollback are created in the working directory, or in the directory specified by the LOCK_DIR configuration variable of the runtime.
  7. The first write or rewrite on a sequential access mode file after a ROLLBACK TRANSACTION will be successful even if the primary key was written out of sequence, and even if the primary key on a rewrite does not match the last record read. No file error 22 will occur. This allows the program to continue where it left off after a rollback.
  8. If the STOP_RUN_ROLLBACK configuration variable is set to 1, an implicit ROLLBACK occurs before a STOP RUN or before the end of the program.