Progress
Embedded SQL-92
Guide and Reference


WHENEVER Statement

Specifies actions for three SQL-92 run-time exceptions.

SYNTAX

WHENEVER 
 { NOT FOUND  |  SQLERROR  |  SQLWARNING  }
     {  STOP  |  CONTINUE  |  {  GOTO  |  GO TO }  host_lang_label  } ; 

NOT FOUND

The NOT FOUND exception is set when sqlca.sqlcode is set to SQL_NOT_FOUND.

SQLERROR

The SQLERROR exception is set when sqlca.sqlcode is set to a negative value.

SQLWARNING

The SQLWARNING exception is set when sqlca.sqlwarn[ 0 ] is set to ’W’ after a statement is executed.

STOP

Results in the ESQLC program stopping execution.

CONTINUE

Results in the ESQLC program continuing execution. The default exception is to CONTINUE.

{ GOTO | GO TO } host_lang_label

Results in the ESQLC program execution to branch to the statement corresponding to the host_lang_label.

EXAMPLES

The first example is a code fragment from the main function in sample program 1StatUpd.pc. The complete source for the sample program is listed in "ESQL-92 Sample Programs."

/*
**  Name WHENEVER routine to handle SQLERROR condition.
*/
EXEC SQL WHENEVER SQLERROR GOTO mainerr ; 

This example is a code fragment from the dynupd function in sample program 3DynUpd.pc, which illustrates dynamic processing of an UPDATE statement. The complete source for the sample program is listed in "ESQL-92 Sample Programs."

/*
**    Name WHENEVER routines to handle NOT FOUND and SQLERROR
*/

EXEC SQL WHENEVER SQLERROR GOTO nodyn ;
EXEC SQL WHENEVER NOT FOUND GOTO nodyn ; 

NOTES

AUTHORIZATION

None.

SQL COMPLIANCE

SQL-92. Progress Extensions: SQLWARNING exception condition and STOP action.

ENVIRONMENT

Embedded SQL-92 only

RELATED STATEMENTS

FETCH Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095