In the PROCEDURE DIVISION, you can use
the WHENEVER command, as at 7 in Title not available,
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 when each subsequent SQL
command is executed:
EXEC SQL WHENEVER SQLERROR GO TO S400-SQL-ERROR END-EXEC.
| |
| |
| |
| 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 SELECT command at 8
causes an error condition, control passes to paragraph S400-SQL-ERROR
because the WHENEVER command shown above precedes
the COMMIT WORK RELEASE and
SELECT commands in the source listing.
The WHENEVER SQLWARNING and WHENEVER NOT FOUND
commands at 7 specify where to pass control when a
warning condition occurs or when no row satisfies the WHERE clause
in the SELECT command.
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.