ContentsIndexPreviousNext

5.1.8 Transaction Error Handling

Error codes associated with transaction management are stored in a special register called TRANSACTION-STATUS. These codes tell you the status of the last transaction and are documented in Appendix J.4. Transaction management errors fall into two categories:

1. For errors that occur during a START TRANSACTION, COMMIT, ROLLBACK, or call to C$RECOVER (see section 5.1.10, "Recovery"), use TRANSACTION-STATUS to determine the type of error that occurred.

2. After the execution of any file operation during a transaction, the file's FILE-STATUS variable will contain 9E if an error occurred in the transaction system. The exact nature of the error will be shown by the contents of TRANSACTION-STATUS.

A subcategory of these errors are "intermediate" runtime errors that call installed error procedures. They are:

· "File error #"

· "File error # on #"

· "Transaction error #"

· "Transaction error # on #"

where the # signs are replaced at run time by error names, numbers, or other information. See Book 4, Appendix I, "Library Routines", for detailed discussion of the error and exit procedures.

The TRANSACTION-STATUS variable has the same format as a file's status variable. It is automatically created by the compiler, and is implicitly shared by all programs of a run unit. TRANSACTION-STATUS is a reserved word.

You can specify procedures for transaction error handling with the USE statement and the reserved word TRANSACTION. The syntax is:

USE AFTER STANDARD {EXCEPTION} PROCEDURE ON TRANSACTION
                   {ERROR    }

If TRANSACTION is specified, the procedure executes when an error occurs during a START TRANSACTION, COMMIT, ROLLBACK, or call to C$RECOVER. See section 5.1.10, "Recovery."


Note that a transaction error 10 is returned by a START TRANSACTION statement when the LOG-FILE configuration variable (that specifies the default log file) is undefined. The COBOL program may choose to ignore this error in the cases where the filename-LOG variables are used.