#docslug#/ecob/ecob/V1.1.6/whatever-statement You can execute the WHENEVER statement to specify the method of handling errors and the alert conditions.
WHENEVER statement description
Syntax:
EXEC SQL WHENEVER (SQLERROR | NOT FOUND) (DO (routine | BREAK | CONTINUE) | CONTINUE | GOTO <label> | STOP )

In this statement, SQLERROR specifies to use the action defined in the current statement to handle an error that occurred while executing the statement. NOT FOUND specifies to use the Action defined in the current statement to handle an exception if no data is found based on the statement.
The following actions are supported:
CONTINUE: Specifies to continue executing the statement. This is the default action of the system, which means no handling of any exception.
DO: Specifies to execute the error handling function.
DO BREAK: Specifies to add the
BREAKstatement to the application. This action is used in theLOOP.DO CONTINUE: Specifies to add the
CONTINUEstatement to the application. This action is used in theLOOP.GOTO label_name: Specifies to jump to
label_nameof the application.STOP: Specifies to stop the application. In this case, the transactions that have not been committed will be rolled back. This action is similar to executing the
EXIT()function.
Notice
The
WHENEVERstatement takes effective to all embedded statements after this statement, especially to theDO BREAKandDO CONTINUEactions. These two actions must be in the loop. Otherwise, an error is returned.If the
DO BREAKorDO CONTINUEaction in the DML statement falls out of the loop, you must reset the error handling method before the statement.
Sample
Sample statement:
{
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL INSERT INTO t1 VALUES(1,'ABC');
...
}
void sqlerror(){
...
}
Sample statement 2:
int c1val;
EXEC SQL DECLARE cur CURSOR FOR select c1 from t1;
EXEC SQL WHENEVER NOT FOUND DO BREAK;
for(;;){
EXEC SQL FETCH cur INTO :c1val;
}