WHENEVER (Declare embedded exception)
Function
WHENEVER declares processing of a UAP, based on the return code (SQLCODE) set in the SQL Communications Area by HiRDB after an SQL has executed.
Format
WHENEVER
{SQLERROR | SQLWARNING | NOT FOUND}
{CONTINUE {GO TO | GOTO} [:]host-identifier
|[DO] PERFORM [:]host-identifier
|DO {break | continue | 'command-statement' }}
Operands
Specifies the processing to be performed when there are no more rows to be retrieved during table retrieval (i.e., when the value 100 is returned to SQLCODE in the SQL Communications Area, the value 100 is returned to the SQLCODE variable, and the value 02000 is returned to the SQLSTATE variable).
Specifies the branching address when execution of the UAP is to branch; following are the host identifiers:
Specifies a procedure that is to be executed; following are the applicable procedure specifications:
Object methods cannot be specified.
This statement either causes branching of the execution of the UAP or executes an arbitrary command statement. The continue command and 'command-statement' can be used in the C and C++ languages.
Common rules
Figure 6-1 Scope of processing specified in WHENEVER declarations
Notes
Figure 6-2 Example of coding a WHENEVER statement (1)
Figure 6-3 Example of coding a WHENEVER statement (2)
Figure 6-4 Example of coding a WHENEVER statement (3)
Figure 6-5 Example of coding a WHENEVER statement (4)
Examples