Example 1: Using WHENEVER statements in a PL/I program
/* When an SQL statement results in
an RDB$_STREAM_EOF error, the
program branches to LABEL_NOT_FOUND: */
EXEC SQL WHENEVER NOT FOUND GOTO LABEL_NOT_FOUND;
/* When an SQL statement results in a
warning severity error condition, the
program branches to LABEL_ERROR: */
EXEC SQL WHENEVER SQLWARNING GOTO LABEL_ERROR;
/* When an SQL statement results in
an error severity exception condition, the
program branches to LABEL_ERROR: */
EXEC SQL WHENEVER SQLERROR GOTO LABEL_ERROR;