EasyManua.ls Logo

HP NonStop SQL/MP

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Error and Status Reporting
HP NonStop SQL/MP Programming Manual for C429847-008
9-9
Using 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,
specify a corresponding indicator variable and test the result of the indicator variable.
Otherwise, NonStop SQL/MP returns an error specifying that no indicator variable was
provided rather than the “not-found” condition. A WHENEVER NOT FOUND directive
does not detect this condition.
Example 9-2. Enabling and Disabling the WHENEVER Directive
EXEC SQL WHENEVER SQLERROR CALL :error_handler;
void fred(short i, short j, short k)
{
EXEC SQL SELECT ...;
EXEC SQL SELECT ...;
EXEC SQL SELECT ...;
}
void ginger(short i, short j, short k)
{
EXEC SQL SELECT ...;
EXEC SQL SELECT ...;
EXEC SQL SELECT ...;
}
/* reset SQLERROR checking while in error handler */
EXEC SQL WHENEVER SQLERROR;
void error_handler(void)
{
EXEC SQL SELECT...;
EXEC SQL SELECT...;
EXEC SQL SELECT...;
}
/* enable SQLERROR checking */
EXEC SQL WHENEVER SQLERROR CALL :error_handler;
int main(void)
{
fred();
ginger();
EXEC SQL INSERT...;
}

Table of Contents

Related product manuals