SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Exception Handling and Error Conditions
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
13-2
SQL:1999 SQLSTATE Values
Examples
In a C program, you must include an extra character for the null terminator. Declare
SQLSTATE within the Declare Section:
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
...
EXEC SQL END DECLARE SECTION;
In a COBOL program, declare SQLSTATE within the Declare Section:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 SQLSTATE PIC X(5).
...
EXEC SQL END DECLARE SECTION END-EXEC.
SQL:1999 SQLSTATE Values
The SQLSTATE variable is a five-character string with two parts. The first part is a
two-character class code, and the second part is a three-character subclass code.
An SQLSTATE value of 00000 indicates successful completion. In C programs,
declare SQLSTATE as type CHAR, with a length of six characters to allow for the null
terminator.
Table 13-1 lists the SQL:1999 SQLSTATE class and subclass values that are
implemented in NonStop SQL/MX.
Table 13-1. SQL:1999 SQLSTATE Class and Subclass Values (page 1 of 2)
Condition Class Subcondition Subclass
Successful completion 00 (No subclass) 000
Warning 01 (No subclass) 000
String data, right truncation 004
Privilege not revoked 006
Privilege not granted 007
No data 02 (No subclass) 000
Dynamic SQL error 07 (No subclass) 000
Invalid descriptor count 008
Invalid descriptor index 009
Feature not supported 0A (No subclass) 000
Cardinality violation 21 (No subclass) 000
Data exception 22 (No subclass) 000
Null, no indicator parameter 002
Numeric value out of range 003
Invalid date-time format 007
C
COBOL