Use the EXEC SQL WHENEVER directive to implement simple error handling for client applications compiled with ECPGPlus. The syntax of the directive is:EXEC SQL WHENEVER condition action;The code instructs the client application that it should perform a specified action if the client application detects a given condition. The condition may be one of the following:A SQLERROR condition exists when sqlca.sqlcode is less than zero.A SQLWARNING condition exists when sqlca.sqlwarn contains a 'W'.A NOT FOUND condition exists when sqlca.sqlcode is ECPG_NOT_FOUND (when a query returns no data).You can specify that the client application perform one of the following actions if it encounters one of the previous conditions:Specify CONTINUE to instruct the client application to continue processing, ignoring the current condition. CONTINUE is the default action.DO CONTINUEAn action of DO CONTINUE will generate a CONTINUE statement in the emitted C code that if it encounters the condition, skips the rest of the code in the loop and continues with the next iteration. You can only use it within a loop.GOTO label
GO TO labelUse a C goto statement to jump to the specified label.Print an error message to stderr (standard error), using the sqlprint() function. The sqlprint() function prints sql error, followed by the contents of sqlca.sqlerrm.sqlerrmc.Call exit(1) to signal an error, and terminate the program.Execute the C break statement. Use this action in loops, or switch statements.CALL name(args)
DO name(args)Invoke the C function specified by the name parameter, using the parameters specified in the args parameter.The following code fragment prints a message if the client application encounters a warning, and aborts the application if it encounters an error:Please Note: The ECPGPlus compiler processes your program from top to bottom, even though the client application may not execute from top to bottom. The compiler directive is applied to each line in order, and remains in effect until the compiler encounters another directive.