Previous Topic: UPDATENext Topic: Control Statements


WHENEVER

The WHENEVER precompiler-directive statement specifies an action to be taken when the execution of an SQL statement results in a nonzero SQLCODE value. The WHENEVER statement directs the precompiler to insert the appropriate conditional code after each subsequent SQL statement that generates a call to CA IDMS

You can use this statement only in SQL that is embedded in a program.

Authorization

None required.

Syntax
►►─── WHENEVER ─┬─ NOT FOUND  ─┬─┬─ CONTINUE ─────────────────────────────┬───►◄
                ├─ SQLERROR ───┤ ├─┬─ GO TO ─┬─┬─ label ──┬─┬─────────────┘
                └─ SQLWARNING ─┘ │ └─ GOTO  ─┘ └─ :label ─┘ │
                                 └─ CALL subroutine-name ───┘
Parameters
NOT FOUND

Directs CA IDMS to take the specified action when the execution of an SQL statement results in an SQLCODE value of 100.

SQLERROR

Directs CA IDMS to take the specified action when the execution of an SQL statement results in an SQLCODE value that is less than zero.

SQLWARNING

Directs CA IDMS to take the specified action when the execution of an SQL statement results in an SQLCODE value of 1.

SQLWARNING is a CA IDMS extension of the SQL standard.

CONTINUE

Specifies that processing is to continue with the next statement.

GO TO label/:label

Specifies that processing is to continue with the first statement at the named label. Label must be the name of a section or the unqualified name of a paragraph in the application program.

GO TO and GOTO are synonyms and can be used interchangeably. Label and :label are synonyms and can be used interchangeably.

The GO TO parameter is not valid in CA ADS application programs.

The specification of a label without a colon (:) is a CA IDMS extension of the SQL standard.

CALL subroutine-name

Specifies that processing control is to pass to the named subroutine. Subroutine-name must identify a subroutine subsequently defined in the process module.

The CALL parameter is valid only in CA ADS process modules.

The CALL parameter is a CA IDMS extension of the SQL standard.

Usage

Scope of the WHENEVER Statement

The WHENEVER statement for a specified condition applies to all subsequent SQL statements until the precompiler encounters another WHENEVER statement that names the same condition.

Example

Specifying Error Processing

The following WHENEVER statement specifies that control is to pass to the section or paragraph named SQLCODE-CHECK whenever CA IDMS returns a negative value in SQLCODE:

EXEC SQL
   WHENEVER SQLERROR
      GO TO :SQLCODE-CHECK
END-EXEC
More Information