Error and Status Reporting
HP NonStop SQL/MP Programming Manual for C—429847-008
9-10
Using the WHENEVER Directive
Example of Using WHENEVER Directives
The code in
Example 9-3
inserts two column values into the PARTS table and checks
for errors and warnings using WHENEVER directives. Within the INSERT statement,
the WHENEVER SQLERROR directive is processed first. This directive has a higher
precedence, although the WHENEVER SQLWARNING directive is specified first in the
source code.
Example 9-3. Using the WHENEVER Directive
(page 1 of 2)
EXEC SQL INCLUDE STRUCTURES ALL VERSION 315;
#define MAX_PARTDESC 19
EXEC SQL BEGIN DECLARE SECTION;
struct
{ short in_partnum;
long in_price;
char in_partdesc[MAX_PARTDESC];
}in_parts_rec;
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA; /* For use with SQLCADISPLAY */
short sqlcode;
short ix; /* Loop counter for blank padding in_partdesc */
/* Specify WHENEVERs globally for errors and warnings: */
EXEC SQL WHENEVER SQLWARNING CALL :handle_warnings;
EXEC SQL WHENEVER SQLERROR CALL :handle_errors;
/* Forward declare error handling code: */
void handle_warnings(void);
void handle_errors(void);
Summary of Contents for NonStop SQL/MP
Page 4: ......
Page 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Page 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Page 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...