Trapping errors with the whenever statement

Use the Embedded SQL whenever statement to trap errors and warning conditions. It specifies actions to be taken depending on the outcome of each Embedded SQL statement sent to Adaptive Server.

The whenever statement is not executable. Instead, it directs the precompiler to generate COBOL code that tests for specified conditions after each executable Embedded SQL statement in the program.

The syntax of the whenever statement is:

exec sql whenever {sqlwarning | sqlerror | 
 not found ]
 {continue | goto label |  
 program call [using param . . .]) |
 perform paragraph_1 [through paragraph_2] | 
 stop};