Embedded Exception Declaration

The clause may be used to define the handling of certain conditions after a query. The result of the query is evaluated and the action as defined in the action clause is executed.

Syntax:
         <embedded exception declaration>  ::=
              WHENEVER <condition>  <condition action> 

         <condition>  ::=
              SQLERROR | NOT FOUND | SQLWARNING

         <condition action>  ::=
                CONTINUE 
              | <go to>  
              | RAISE <host_exception>  
              | DO <target> 
              | STOP

         <go to>  ::=
              { GOTO | GO TO } <goto target> 

         <goto target>  ::=
               <host label identifier> 

   

A defined condition is applies to the next SQL query. By using the switch -noiso92 the code generator may be forced to apply whenever clause to all embedded SQL statements until the next whenever clause occurs.

Table 14-1. Exception Actions

GOTOThe translator inserts a goto statement to the label specified in the target.
RAISEThe translator inserts a raise statement with an exception as specified in the target. The exception information will contain the line number of the query in the input source file and the package name. Additionally the contents of the message in the SQLCA is added.
DOThe procedure named in the target specification is called.
CONTINUEThis clause will reset all previous actions for the given condition.