HP 3000 Manuals

Implicit Status Checking [ ALLBASE/SQL COBOL Application Programming Guide ] MPE/iX 5.0 Documentation


ALLBASE/SQL COBOL Application Programming Guide

Implicit Status Checking 

In the PROCEDURE DIVISION, you can use the WHENEVER command, as at  7  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 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.



MPE/iX 5.0 Documentation