Technical data
USE
General Rules
All Formats
1. At run time, two special precedence rules apply for the selection of a USE
procedure when a program is contained within another program. In applying
these rules, only the first qualifying USE procedure is selected for execution.
The order of precedence for the selection of a USE procedure is as follows:
• First, select the USE procedure within the program containing the
statement that caused the qualifying condition.
• If a USE procedure is not found in the program using the previous
rule, the Run-Time System searches all programs directly or indirectly
containing that program for a USE GLOBAL . . . Declaratives procedure.
This search continues until the Run-Time System either: ( a ) finds
an applicable USE GLOBAL Declaratives procedure, or ( b ) finds the
outermost containing program, if there is no applicable USE GLOBAL
Declaratives. Either condition terminates the search.
2. A USE procedure cannot refer to a non-Declaratives procedure. However, only
the PERFORM statement can transfer execution control from:
• A Declaratives procedure to another Declaratives procedure
• A non-Declaratives procedure to a Declaratives procedure
3. After a USE procedure executes, control returns to the next executable
statement in the invoking routine, if one is defined. Otherwise, control
transfers according to the rules for Explicit and Implicit Transfers of Control.
4. A program must not execute a statement in a USE procedure that would
cause execution of a USE procedure that had been previously executed and
had not yet returned control to the routine that invoked it.
Format 3
5. Prior to the execution of a database USE procedure, the DBCS places
appropriate values in the DB-CONDITION, DB-CURRENT-RECORD-NAME,
and DB-CURRENT-RECORD-ID special registers.
6. A database USE procedure executes automatically:
• After standard database exception condition processing ends
• When an on error condition or an at end condition results from a COBOL
DML (data manipulation language) statement that has no applicable ON
ERROR or AT END clause
7. Use of a DML verb in a USE FOR DB-EXCEPTION is not supported.
8. If there is an applicable USE FOR DB-EXCEPTION procedure, it executes
whenever a database exception condition occurs. However, it does not execute
if: ( a ) the condition is at end and there is an AT END phrase or ( b ) the
condition is any database exception and there is an ON ERROR phrase.
9. If the DBCS (Database Control System) detects more than one database
exception condition during the execution of a COBOL DML statement, the
database USE procedure to which control transfers is determined by the
contents of DB-CONDITION.
10. One COBOL DML error cannot cause more than one USE FOR DB-
EXCEPTION procedure to execute.
Procedure Division 4–63