Technical data
The NOT ON ERROR phrase allows execution of an imperative statement when
a database exception condition does not occur.
The format is as follows:
NOT
ON ERROR stment
Stment is an imperative statement.
When a database exception condition occurs and the statement contains an ON
ERROR phrase:
1. The imperative statement associated with the ON ERROR phrase executes.
2. The NOT ON ERROR phrase, if specified, is ignored.
3. Control is transferred to the end of database statement unless control has
been transferred by executing the imperative statement of the ON ERROR
phrase.
When a database exception condition occurs and the statement does not contain
an ON ERROR phrase:
1. The applicable USE FOR DB-EXCEPTION, if specified, executes.
2. If an applicable USE procedure does not exist, the run unit terminates
abnormally.
3. The NOT ON ERROR phrase, if specified, is ignored.
When a database exception condition does not occur:
1. The imperative statement associated with the NOT ON ERROR phrase, if
specified, is executed.
2. The ON ERROR phrase, if specified, is ignored.
3. Control is transferred to the end of the database statement unless control
has been transferred by executing the imperative statement of the NOT ON
ERROR phrase.
Use the ON ERROR phrase to transfer execution control to the associated
statements’ error handling routine, where your program can supply useful and
effective debugging information. (See Section 4.8.3 for examples and Glossary of
Oracle DBMS-Related Terms for more information on Oracle CODASYL DBMS
Database Special Registers.) The ON ERROR phrase can be part of every DML
statement. It allows you to plan the graceful termination of a program that
would otherwise terminate abnormally. (In a FETCH or FIND statement, you
cannot specify both the ON ERROR and AT END phrases in the same statement.)
For example:
PROCEDURE DIVISION.
.
.
.
RECONNECT PARTS_RECORD WITHIN ALL
ON ERROR DISPLAY "Exception on RECONNECT"
PERFORM PROCESS-EXCEPTION.
4–16 Procedure Division