Trapping errors with whenever

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 C 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 |  
 call function_name ([param [, param]...]) | stop};