SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-87
C Examples of WHENEVER
C Examples of WHENEVER
The effect of this statement is the same as if you had written a C statement that
tests for an SQLSTATE of 02000 and executes a C continue statement:
WHENEVER NOT FOUND CONTINUE;
WHENEVER sets actions for all embedded SQL statements that physically follow it
in the program. In this example, if statement_2 caused an error, control
continues at label x.
...
EXEC SQL statement_1;
EXEC SQL WHENEVER SQLERROR GOTO label_x;
EXEC SQL statement_2;
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL statement_3;
...
label_x:
...
COBOL Examples of WHENEVER
For more COBOL examples, see the SQL/MX Programming Manual for C and
COBOL.
The effect of this statement is the same as if you had written a COBOL statement
that tests for an SQLSTATE of 02000 and executes a COBOL NEXT SENTENCE
statement:
WHENEVER NOT FOUND CONTINUE END-EXEC.
WHENEVER sets actions for all embedded SQL statements that physically follow it
in the program. In this example, if statement_2 caused an error, control
continues at paragraph x:
...
EXEC SQL statement_1 END-EXEC.
EXEC SQL WHENEVER SQLERROR GOTO para-x END-EXEC.
EXEC SQL statement_2 END-EXEC.
EXEC SQL WHENEVER SQLERROR CONTINUE END-EXEC.
EXEC SQL statement_3 END-EXEC.
...
para-x.
...