You can use the WHENEVER command, as at 6 in Figure 3-1,
to have ALLBASE/SQL examine SQLCA values and
cause a specific action to be taken.
The WHENEVER command is a preprocessor directive that specifies
the action to be taken if an error or warning
condition occurs during each execution of the SQL
command:
EXEC SQL WHENEVER SQLERROR CONTINUE;
| |
| |
| |
| the action
|
the condition
|
Each WHENEVER command affects all ALLBASE/SQL commands that follow it in
the source listing until another WHENEVER command is encountered.
If execution of
the COMMIT WORK RELEASE command at 7
or the SELECT command at 8
causes an error condition, ALLBASE/SQL takes no special action.
This occurs because the WHENEVER command shown above precedes
the COMMIT WORK RELEASE and
SELECT commands in the source listing.
The WHENEVER SQLERROR command at 6 turns off the
implicit status checking of the WHENEVER SQLERROR
command that appears
earlier in the source listing:
EXEC SQL WHENEVER SQLERROR goto 1000;
|
This WHENEVER command specifies where
to pass control when an error occurs
during execution of the CONNECT, BEGIN WORK, or COMMIT WORK commands.
Although you can use a WHENEVER command to have ALLBASE/SQL
examine the
values in certain fields of the SQLCA, you can
also examine the values yourself, as discussed under
"Explicit Status Checking" later in this chapter.