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 values of the SQLSTATE variable that can be set by HiRDB 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) |
mm | nnn | Abnormal termination |
mm: When no class is assigned, R0 is set as the default.
nnn: When no subclass is assigned, 000 is set as the default.
The values of mm and nnn are subject to change due to functional expansions of HiRDB.