Scalable Database Server, HiRDB Version 8 UAP Development Guide
HiRDB sets up return codes (SQLCODE and SQLSTATE) when SQL statements execute. However, HiRDB does not set return codes for declaration statements, such as DECLARE CURSOR. The following variables can be used to reference the return codes:
An SQL statement's execution status can be determined by referencing the SQLCODE and SQLSTATE variables.
Table 3-26 shows the SQL statement execution status indicated by the values set in the variables.
Table 3-26 Values set in variables and SQL statement execution status
SQL statement execution status | SQLCODE variable value | SQLWARN0 value | SQLWARN6 value | SQLSTATE variable value | |
---|---|---|---|---|---|
Normal termination | Without warning | 0 | '' | '00000' | |
With warning4 | 0 | 'W' | '01nnn'1 (nnnR00) |
||
>0 ( 100, 110) | 'R01R00' | ||||
Without data3 | 110 | 'R2000' | |||
No data | 100 | '02000' | |||
Termination with error | Without implicit rollback | <0 | '' | 'mmnnn'2 | |
With implicit rollback | <0 | 'W' | 'W' | '40nnn'1 |
mm: Class
nnn: Subclass
: No value is set.
For details about the contents of the SQLWARN0 to SQLWARNF areas, see A. SQL Communications Area.
If warning information is indicated with an SQLCODE value (positive number other than 100), the SQLSTATE subclass (nnn) becomes R00. Table 3-27 shows the relationships among the SQLSTATE, SQLCODE, and SQLWARN0 values if normal termination with warning occurs.
Table 3-27 Relationship among SQLSTATE, SQLCODE, and SQLWARN0 values when normal termination with a warning occurs
SQLSTATE value | SQLCODE value | SQLWARN0 value |
---|---|---|
01nnn (nnnR00) | 0 | 'W' |
01R00 | Positive number other than 100 | Blank or 'W' |
The UAP determines that there are no more rows to be retrieved.
This setting is useful for determining the following:
The UAP determines that an SQL error occurred.
If an SQL error occurred, implicit rollback may also have occurred. If SQLWARN6='W' or SQLSTATE='40nnn', the UAP determines that implicit rollback occurred.
To identify the SQL statement that caused the error, check the SQL trace information. For details about the SQL trace information, see 10.1.1 SQL tracing.
The UAP determines that the SQL statements terminated normally. Normal termination may come with warning information. If SQLWARN0='W', SQLCODE is a positive value other than 100, or SQLSTATE='01nnn', the UAP determines that normal termination with warning occurred.
When a search using a list is executed, normal termination without any data (a row that was present when the list was created has been deleted) may occur. If SQLCODE is 110 or SQLSTATE is 'R2000', the UAP must determine that normal termination without any data occurred and skip the processing for selection rows.
For details about normal termination with warning, see Table 3-27.
When you detect an error, use the following procedure:
Table 3-28 Additional return code information and items referred to by the information
Additional information | Referenced item |
---|---|
Message concerning SQLCODE* | SQLERRML field in SQL Communications Areas and contents of SQLERRMC field |
When a distributed system is used, information that identifies the source of the error in terms of the local RD node vs. other nodes | Contents of SQLCAIDE field of SQL Communications Areas |
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.