Previous Topic: WHERE ClauseNext Topic: Logical-Record Status Codes


ON Clause

The ON clause tests for a specific path status returned to indicate the result of a logical record request. If LRF returns the specified path status, the imperative statement included in the ON clause is executed. The imperative statement usually consists of a GOTO statement. If the path status is not returned, the imperative statement included in the ON clause is ignored.

Note: Only one ON clause can be coded per logical record DML statement; only one specific path status can be tested for.

Standard Path Statuses

Path statuses are issued during execution of the path selected to service the request. The following standard path statuses can be returned:

When accessing ASF-defined data tables, you should always check for all of the following path statuses:

The return of one or more of these path statuses indicates a fatal error. For more information, consult your DBA.

Syntax

►─┬─────────────────────────────────────────────┬────────────────────────────►
  └─ ,ONLRSTS=path-status,GOTO=branch-location ─┘

Parameters

ONLRSTS=path-status

Tests for a path status returned as the result of the logical-record request issued by the program. Path-status must be a quoted literal (1 to 16 bytes under z/OS or 1 to 6 bytes under z/VSE) or a program variable.

Note: In addition to testing for a specific path status (using ONLRSTS), your program should check for standard path statuses (for example, LR-NOT-FOUND and LR-ERROR, and path statuses for ASF defined tables if applicable) whenever the program issues a logical record request.

GOTO=branch-location

Specifies the program action to be taken if the indicated path status results from the logical-record request.

Example

The following ON clause causes the program to branch to the NOFFICE label when the path status specified in the variable NOOFF is met. NOOFF indicates a path status indicating that there are no offices that meet the criteria specified in the WHERE clause. Standard LRF path statuses are checked as well.

@OBTAIN REC=EMPJOBLR,                                        *
      ONLRSTS=NOOFF,GOTO=NOFFICE,                            *
      WHERE OFFICE-CODE-0450 EQ '0980'
CLC   LRSTAT,=CL16'LR-FOUND'
BE    CRDITREF
CLC   LRSTAT,=CL16'LR-ERROR'
BE    LRERRTN
CLC   LRSTAT,=CL16'LR-NOT-FOUND'
BE    LRNTFND