SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Exception Handling and Error Conditions
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
13-10
SQLCODE Values
mxsqlc a.sql -c a.cpp -m a.mdf -w both
*** WARNING[13086] SQLSTATE is not declared of type char[6]
inside the Declare Section.
*** WARNING[13025] Warning(s) near line 8.
*** WARNING[13085] SQLCODE is not declared inside the Declare
Section.
*** WARNING[13025] Warning(s) near line 11.
*** WARNING[13085] SQLCODE is not declared inside the Declare
Section.
*** WARNING[13085] SQLSTATE is not declared inside the
Declare Section.
*** WARNING[13025] Warning(s) near line 16.
SQLCODE Values
After the execution of an embedded SQL statement, NonStop SQL/MX returns the
values listed in Table 13-5 to SQLCODE. The SQL message numbers described under
Using the WHENEVER Statement on page 13-13 are SQLCODE values except for the
special values 0 and 100. The SQL message numbers that indicate errors are stored
as negative numbers, and the SQL message numbers that indicate warnings are
stored as positive numbers.
Using SQLCODE
You can declare SQLCODE as a global variable at the start of each source unit that
contains embedded SQL statements. You can then use conditional statements to
check the SQLCODE variable after the execution of an SQL statement.
This example checks the SQLCODE variable for any errors or warnings after an
INSERT statement:
Examples
...
/* global C declarations */
long SQLCODE; /* Declare SQLCODE with data type long. */
...
... /* Set new_jobcode and new_jobdesc host variables. */
Table 13-5. SQLCODE Values
Value Status
< 0 An error occurred.
> 0 (<>100) A warning occurred.
100 No data was found.
0 The statement completed successfully.
C