SQL/MP Programming Manual for COBOL85

Error and Status Reporting
HP NonStop SQL/MP Programming Manual for COBOL85429326-004
9-9
Using the WHENEVER Directive
To avoid these situations, disable the appropriate WHENEVER directive for the part of
your program that handles the condition. Example 9-2 on page 9-10 enables and
disables the WHENEVER directive.
Using an Aggregate Function
All aggregate functions except COUNT return a null value when operating on an empty
set. If a host variable receives the null value as the result of an aggregate function, you
must specify an indicator variable and test the result of the indicator variable.
Otherwise, SQL/MP returns a “no indicator variable provided” condition instead of a “no
rows found” condition. A WHENEVER NOT FOUND directive does not detect this
condition.
Example 9-2 on page 9-10 illustrates the use of WHENEVER directives that detect
error and warning conditions. For the INSERT statement, the SQLERROR directive is
processed first. This directive has a higher precedence, although the SQLWARNING
directive is specified first in the source code.