WHENEVER condition action
Syntax Elements
- condition
- A status keyword that indicates the type of condition for which the indicated action is to be undertaken.
- The valid condition keywords and their definitions are listed in the following tables.
- Following each keyword is the definition of the values for the SQLCODE and SQLSTATE variables when the condition occurs.
- When SQLERROR is a condition in which an SQL error occurs:
- SQLCODE has the following value: <0
- When NOT FOUND is a condition in which no data is found:
- SQLCODE has the following value: +100
- SQLSTATE has the following value: 02xxx
- When SQLWARNING is a condition in which an SQL warning occurs (SQLWARNING is a non-ANSI Teradata extension):
- SQLCODE has the following value: a positive number other than +100
- SQLSTATE is not defined.
- action
- The action to be run when condition occurs.
- The valid actions are:
- CONTINUE
- GO TO :host_label
- GOTO :host_label
- PERFORM code
- CALL function_call
- where:
- :host_label specifies a valid target of a client language GO TO statement. Use of a preceding colon is strongly recommended.
- code specifies the name of a section or paragraph in the application to be run when the exception condition occurs. The PERFORM action is valid only for COBOL.
- function_call specifies the function to be called when the exception condition occurs.