Technical data
4.8.3 Exception Conditions and the USE Statement
Planning for exception conditions is an effective way to increase program and
programmer productivity. A program with USE statements is more flexible than
a program without them. They minimize operator intervention and often reduce
or eliminate the time you need to debug and rerun the program.
The USE statement traps unsuccessful run-time Oracle CODASYL DBMS
exception conditions that cause the execution of a Declaratives procedure. A
Declaratives procedure can:
• Supply useful and effective database debugging information (see Section 2.2
for more information on Oracle CODASYL DBMS Database Special Registers)
• Provide alternate processing paths for specific exception conditions
Two sets of USE statements follow:
• The first set, shown in Example 4–1, consists of a single USE statement.
This database USE procedure executes for any and all database exception
conditions. If you select this set, it must be the only database USE statement
in the Declaratives Section. Its format is:
USE [ GLOBAL ] FOR DB-EXCEPTION.
Example 4–1 A Single USE Statement
PROCEDURE DIVISION.
DECLARATIVES.
200-DATABASE-EXCEPTIONS SECTION. USE FOR DB-EXCEPTION.
DB-ERROR-ROUTINE.
DISPLAY "Database Exception Condition Report".
DISPLAY "-------------------------------------------".
DISPLAY "DB-CONDITION = ", DB-CONDITION
WITH CONVERSION.
DISPLAY "DB-CUR-REC-NAME = ", DB-CURRENT-RECORD-NAME.
DISPLAY "DB-CURRENT-RECORD-ID = ", DB-CURRENT-RECORD-ID
WITH CONVERSION.
DISPLAY "DB-CUR-REC-ID = ", DB-CRID.
DISPLAY " ".
CALL "DBM$SIGNAL".
END DECLARATIVES.
• The second set, shown in Example 4–2, consists of one or more Format 1 USE
statements, and one Format 2 USE statement.
Format 1
maximum
USE [GLOBAL] FOR DB-EXCEPTION ON DBM$_exception-condition [, DBM$_exception-condition]...
A Format 1 database declarative executes whenever a database exception
condition occurs and the corresponding DBM$_exception-condition is explicitly
stated in the USE statement.
Format 2
USE [ GLOBAL ] FOR DB-EXCEPTION ON OTHER.
4–18 Procedure Division