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.

ClassSubclassCondition
00000Normal termination
01nnnNormal termination (with warning)
02000No data
40nnnAbnormal termination (transaction was rolled back)
R2000No data (in searches using a list, however, data sometimes exists in the row that is returned when the list is created)
mmnnnAbnormal termination
Notes
The meanings of mm and nnn are as follows.
mm: The SQLSTATE class is set as described in the manual HiRDB Version 9 Messages.
nnn: The SQLSTATE subclass is set as described in the manual HiRDB Version 9 Messages.
However, mm and nnn may vary depending on the value of the HiRDB facility extensions.