WHENEVER Directive

The WHENEVER directive controls the flow of the program in the event it encounters an error, warning, or NOT FOUND condition. Note that NOT FOUND conditions are the result of a SELECT or FETCH operation. See SELECT Statement and FETCH Statement for more information on SELECT and FETCH.

Syntax

EXEC SQL WHENEVER  {SQLERROR}   | {CONTINUE}
                   {SQLWARNING} | {PERFORM paragraph}
                   {NOT FOUND}  | {GO TO paragraph}
                                | {STOP}

where paragraph is a specified procedure in the program.

Example

The following statement appears in the create.sqb program:

EXEC SQL WHENEVER SQLERROR GO TO Error-Exit END-EXEC.

This indicates that when the program encounters an error condition, it proceeds to the Error-Exit routine. See SQL Verbs for additional information on the WHENEVER directive.