SQLSTATE variable
When an SQL is executed, HiRDB sets a return code (SQLSTATE). The SQLSTATE variable is a 5-digit character string composed of a 2-digit class and a 3-digit subclass.
Because the system includes the necessary declaration statement in the source program during preprocessing, the SQLSTATE variable does not need to be declared in the UAP. In C language, the data type of the SQLSTATE variable is declared as char[5].; in COBOL, it is declared as PIC X(5).
To reference the SQLSTATE variable, the variable name SQLSTATE must be specified.
In an environment that uses the multi-connection facility, the connection handle used by SQLSTATE must be declared with DECLARE CONNECTION HANDLE SET.
The value to which SQLSTATE is set depends on the settings of the client environment variable PDSTANDARDSQLSTATE and of pd_standard_sqlstate in the system common definition. For details about SQLSTATE, see the manual HiRDB Version 9 Messages.
The meaning of the classes and their relationships to subclasses are shown below.
Class | Subclass | Condition |
---|---|---|
00 | 000 | Normal termination |
01 | nnn | Normal termination (with warning) |
02 | 000 | No data |
40 | nnn | Abnormal termination (transaction was rolled back) |
R2 | 000 | No data (in searches using a list, however, data sometimes exists in the row that is returned when the list is created) |
mm | nnn | Abnormal termination |