Example

The following statements can be embedded in a COBOL program.

Example 1: Go to the label HANDLER for any statement that produces an error.

  EXEC SQL  WHENEVER SQLERROR GOTO HANDLER  END-EXEC.

Example 2: Continue processing for any statement that produces a warning.

  EXEC SQL  WHENEVER SQLWARNING CONTINUE  END-EXEC.

Example 3: Go to the label ENDDATA for any statement that does not return data when expected to do so.

  EXEC SQL  WHENEVER NOT FOUND GOTO ENDDATA  END-EXEC.