Nonstop Database, HiRDB Version 9 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.
The following table shows the relationships between SQL statement execution status and the values set in variables.
Table 3-28 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 warning#4 | 0 | 'W' | -- | '01nnn'#1 (nnn |
|
>0 ( |
-- | -- | 'R01R00' | ||
Without data#3 | 110 | -- | -- | 'R2000' | |
No data | 100 | -- | -- | '02000' | |
Termination with error | Without implicit rollback | -1 to -1999 | -- | ' |
'mmnnn'#2 |
With implicit rollback | -1 to -1999 | '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. The following table shows the relationships among the SQLSTATE, SQLCODE, and SQLWARN0 values when normal termination with a warning occurs.
Table 3-29 Relationship among SQLSTATE, SQLCODE, and SQLWARN0 values when normal termination with a warning occurs
SQLSTATE value | SQLCODE value | SQLWARN0 value |
---|---|---|
01nnn (nnn |
0 | W |
01R00 | Positive number other than 100 | Null 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 11.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-29.
When you detect an error, use the following procedure:
Table 3-30 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 |
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.