SQL/MP Programming Manual for C
Error and Status Reporting
HP NonStop SQL/MP Programming Manual for C—429847-008
9-11
Using the WHENEVER Directive
int main(void)
{
/* Begin TMF transaction: */
 EXEC SQL BEGIN WORK;
 in_parts_rec.in_partnum = 4120;
 in_parts_rec.in_price = 6000000;
 strcpy (in_parts_rec.in_partdesc,"V8 DISK OPTION");
/* Blank pad in_partdesc. "V8 DISK OPTION" occupies */
/* positions 0 through 13; start blank padding at */
/* position 14: */
 for (ix = 14; ix < 
; ix++)
 in_parts_rec.in_partdesc[ix] = ' ';
...
/* Do an SQL INSERT into the parts table: */
 EXEC SQL
 INSERT INTO =parts (partnum, price, partdesc)
 VALUES ( :in_parts_rec.in_partnum,
 SETSCALE (:in_parts_rec.in_price, 2),
 :in_parts_rec.in_partdesc);
/* End TMF transaction: */
 EXEC SQL COMMIT WORK;
}
void handle_errors(void)
{
 SQLCADISPLAY( (short *) &sqlca);
 exit(EXIT_FAILURE);
}
void handle_warnings(void)
{
 warning_sum++;
 SQLCADISPLAY( (short *)&sqlca,,,,'N','Y');
}
Example 9-3. Using the WHENEVER Directive (page 2 of 2)










