EasyManua.ls Logo

Sybase Adaptive Server Anywhere - WHENEVER Statement [ESQL]

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
WHENEVER statement [ESQL]
646
WHENEVER statement [ESQL]
Use this statement to specify error handling in embedded SQL programs.
WHENEVER { SQLERROR | SQLWARNING | NOTFOUND }
GOTO
label
| STOP | CONTINUE | {
C
code;
}
label
:
identifier
None.
None.
The WHENEVER statement is used to trap errors, warnings and exceptional
conditions encountered by the database when processing SQL statements.
The statement can be put anywhere in an embedded SQL program and does
not generate any code. The preprocessor will generate code following each
successive SQL statement. The error action remains in effect for all
embedded SQL statements from the source line of the WHENEVER
statement until the next WHENEVER statement with the same error
condition, or the end of the source file.
Errors based on source position
The error conditions are in effect based on positioning in the C language
source file, not based on when the statements are executed.
The default action is CONTINUE.
Note that this statement is provided for convenience in simple programs.
Most of the time, checking the sqlcode field of the SQLCA (SQLCODE)
directly is the easiest way to check error conditions. In this case, the
WHENEVER statement would not be used. If fact, all the WHENEVER
statement does is cause the preprocessor to generate an if ( SQLCODE ) test
after each statement.
SQL/92 Entry-level feature.
Sybase Supported by Open Client/Open Server.
The following are examples of the WHENEVER statement:
EXEC SQL WHENEVER NOTFOUND GOTO done;
EXEC SQL WHENEVER SQLERROR
{
PrintError( &sqlca );
return( FALSE );
};
Function
Syntax
Permissions
Side effects
Description
Standards and
compatibility
Examples

Table of Contents

Related product manuals