
Error and Status Reporting
HP NonStop SQL/MP Programming Manual for C—429847-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...;
}
Содержание NonStop SQL/MP
Страница 4: ......
Страница 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Страница 34: ...Introduction HP NonStop SQL MP Programming Manual for C 429847 008 1 8 SQL MP Version Management ...
Страница 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Страница 68: ...SQL MP Statements and Directives HP NonStop SQL MP Programming Manual for C 429847 008 3 8 Finding Information ...
Страница 156: ...Explicit Program Compilation HP NonStop SQL MP Programming Manual for C 429847 008 6 40 SQL Program Files ...
Страница 264: ...Dynamic SQL Operations HP NonStop SQL MP Programming Manual for C 429847 008 10 66 Detailed Dynamic SQL Program ...
Страница 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...
Страница 300: ...Memory Considerations HP NonStop SQL MP Programming Manual for C 429847 008 B 6 Avoiding Memory Stack Overflows ...
Страница 304: ...Maximizing Local Autonomy HP NonStop SQL MP Programming Manual for C 429847 008 C 4 Skipping Unavailable Partitions ...