Oracle7 Server SQL Reference

Contents Index Home Previous Next

WHENEVER (Embedded SQL)

Purpose

To specify the action to be taken when if error an warning results from executing an embedded SQL program.

Prerequisites

None.

Syntax

Keywords and Parameters

NOT FOUND

identifies any exception condition that results in a return code of +100 in SQLCODE, (or +1403 in Version 5 compatibility mode).

SQLERROR

identifies a condition that results in a negative return code.

SQLWARNING

identifies a non-fatal warning condition.

CONTINUE

indicates that the program should progress to the next statement.

GOTO

indicates that the program should branch to the statement named by label_name.

STOP

stops program execution.

DO

indicates that the program should call a host language routine. The syntax of routine_call depends on your host language. See your language-specific Supplement to the Oracle Precompilers Guide.

Usage Notes

The WHENEVER command allows your program to transfer control to an error handling routine in the event an embedded SQL statement results in an error or warning.

The scope of a WHENEVER statement is positional, rather than logical. A single WHENEVER statement applies to all embedded SQL statements that physically follow it in the Precompiler source file, not in the flow of the program logic. A WHENEVER statement remains in effect until it is superseded by another WHENEVER statement checking for the same condition.

For more information on this command, see Programmer's Guide to the Oracle Precompilers.

Do not confuse the WHENEVER embedded SQL command with the WHENEVER SQL*Plus command.

Example

The example illustrates the use of the WHENEVER command in a Pro*C embedded SQL program:

EXEC SQL WHENEVER NOT FOUND; 
... 
EXEC SQL WHENEVER SQLERROR GOTO sqlerror: 
... 
sql_error: 
	EXEC SQL WHENEVER SQLERROR CONTINUE; 
	EXEC SQL ROLLBACK RELEASE; 

Related Topics

None


Contents Index Home Previous Next