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-5
Checking the sqlcode Variable
Example 9-1. Checking the sqlcode Variable
EXEC SQL INCLUDE STRUCTURES ALL VERSION 315;
/* Variable declarations: */
EXEC SQL BEGIN DECLARE SECTION;
struct
{ short in_partnum;
long in_price;
char in_partdesc[19];
}in_parts_rec;
EXEC SQL END DECLARE SECTION;
/* Include the SQLCA for detailed error information */
EXEC SQL INCLUDE SQLCA;
/* Include sqlcode for simple error checking */
short sqlcode;
...
void do_sql_insert(void)
{
/* Do an SQL INSERT into the parts table: */
in_parts_rec.in_partnum = 4120;
in_parts_rec.in_price = 6000000;
/* IN_PRICE value is multiplied by 100 to reflect scale */
strcpy (in_parts_rec.in_partdesc,"V8 DISK OPTION ");
EXEC SQL INSERT INTO sales.parts (partnum, price, partdesc)
VALUES ( :in_parts_rec.in_partnum,
SETSCALE (:in_parts_rec.in_price, 2),
:in_parts_rec.in_partdesc);
/* The SETSCALE function represents the scale to SQL */
/* Check any for errors and warnings: */
if (sqlcode < 0) handle_errors();
if (sqlcode > 0 && sqlcode != 100) handle_warnings();
...
} /* End of do_sql_insert */

Table of Contents

Related product manuals