Field descriptions

The names in the following table are those provided by the SQL INCLUDE statement.

For the most part, C (and C++), COBOL, and PL/I use the same names. RPG names are different, because in RPG/400®, they are limited to 6 characters. In ILE RPG, both a long name and the short 6 character name is supported. Note one instance where PL/I names differ from the COBOL names.

Table 1. Names Provided by the SQL INCLUDE Statement
C Name
COBOL Name
PL/I Name
ILE RPG Name
RPG/400 Name
Field
Data Type
Field Value
SQLCAID
sqlcaid
SQLCAID
SQLAID
CHAR(8) An eye catcher for storage dumps, containing 'SQLCA'.
SQLCABC
sqlcabc
SQLCABC
SQLABC
INTEGER Contains the length of the SQLCA, 136.
SQLCODE
sqlcode
SQLCODE
SQLCOD
INTEGER Contains an SQL return code.
Code
Meaning
0
Successful execution although SQLWARN indicators might have been set.
positive
Successful execution, but with a warning condition.
negative
Error condition.
SQLERRML1
sqlerrml
SQLERRML
SQLERL
SMALLINT Length indicator for SQLERRMC, in the range 0 through 70. 0 means that the value of SQLERRMC is not pertinent.
SQLERRMC1
sqlerrmc
SQLERRMC
SQLERM
CHAR(70) Contains message replacement text associated with the SQLCODE. For CONNECT and SET CONNECTION, the SQLERRMC field contains information about the connection, see Table 4 for a description of the replacement text.
SQLERRP
sqlerrp
SQLERRP
SQLERP
CHAR(8) Contains the name of the product and module returning the error or warning. The first three characters identify the product:
  • ARI for DB2® for VM and VSE
  • DSN for DB2 for z/OS®
  • QSQ for Db2® for i
  • SQL for all other DB2 products
See CONNECT (type 1) or CONNECT (type 2) for additional information.
SQLERRD
sqlerrd
SQLERRD
SQLERR2
Array Contains six INTEGER variables that provide diagnostic information, see Table 3 for a description of the diagnostic information.
SQLWARN
sqlwarn
SQLWARN
SQLWRN3
CHAR(11) A set of 11 CHAR(1) warning indicators, each containing blank or 'W' or 'N'.
SQLSTATE
sqlstate
SQLSTATE
SQLSTT
CHAR(5) A return code that indicates the outcome of the most recently executed SQL statement.
Notes:
1
In COBOL, SQLERRM includes SQLERRML and SQLERRMC. In PL/I, the varying-length string SQLERRM is equivalent to SQLERRML prefixed to SQLERRMC.
2
In RPG/400, SQLERR is defined as 24 characters (not an array) that are redefined by the fields SQLER1 through SQLER6. The fields are full-word binary. In ILE RPG, SQLERR is also redefined as an array. The name of the array is SQLERRD.
3
In RPG/400, SQLWRN is defined as 11 characters (not an array) that are redefined by the fields SQLWN0 through SQLWNA. The fields are full-word binary. In ILE RPG, SQLWRN is also redefined as an array. The name of the array is SQLWARN.
Table 2. SQLWARN Diagnostic Information
C Name
COBOL Name
PL/I Name
ILE RPG Name
RPG/400 Name
Field Value
SQLWARN0
sqlwarn[0]
SQLWARN(1)
SQLWN0
Contains 'W' if at least one other indicator contains 'W' or 'N', it is blank if all other indicators are blank.
SQLWARN1
sqlwarn[1]
SQLWARN(2)
SQLWN1
Contains 'W' if the value of a string column was truncated when assigned to a host variable. Contains 'N' if *NOCNULRQD was specified an the CRTSQLCI or CRTSQLCPPI command (or CNULRQD(*NO) on the SET OPTION statement) and if the value of a string column was assigned to a C NUL-terminated host variable and if the host variable was large enough to contain the result but not large enough to contain the NUL-terminator.
SQLWARN2
sqlwarn[2]
SQLWARN(3)
SQLWN2
Contains 'W' if the null values were eliminated from the argument of a function; not necessarily set to 'W' for the MIN or MAX function because its results are not dependent on the elimination of null values.
SQLWARN3
sqlwarn[3]
SQLWARN(4)
SQLWN3
Contains 'W' if the number of columns is larger than the number of host variables.
SQLWARN4
sqlwarn[4]
SQLWARN(5)
SQLWN4
Contains 'W' if a prepared UPDATE or DELETE statement does not include a WHERE clause.
SQLWARN5
sqlwarn[5]
SQLWARN(6)
SQLWN5
Contains a character value of 1 (read only), 2 (read and delete), or 4 (read, delete, and update) to reflect capability of a cursor after the OPEN statement.
SQLWARN6
sqlwarn[6]
SQLWARN(7)
SQLWN6
Contains 'W' if date arithmetic results in an end-of-month adjustment.
SQLWARN7
sqlwarn[7]
SQLWARN(8)
SQLWN7
Reserved
SQLWARN8
sqlwarn[8]
SQLWARN(9)
SQLWN8
Contains 'W' if the result of a character conversion contains the substitution character.
SQLWARN9
sqlwarn[9]
SQLWARN(10)
SQLWN9
Reserved
SQLWARNA
sqlwarn[10]
SQLWARN(11)
SQLWNA
Reserved
Table 3. SQLERRD Diagnostic Information
C Name
COBOL Name
PL/I Name
ILE RPG Name
RPG/400 Name
Field Value
SQLERRD(1)
sqlerrd[0]
SQLERRD(1)
SQLER1
Contains the last four characters of the CPF escape message if SQLCODE is less than 0. For example, if the message is CPF5715, X'F5F7F1F5' is placed in SQLERRD(1).1

For a call to a procedure, contains the return status value specified on the RETURN statement. If a return status value is not specified on the RETURN statement or the procedure is an external procedure,

  • 0 is returned if the CALL statement is successful, or
  • –1 is returned if the CALL statement is not successful.
SQLERRD(2)
sqlerrd[1]
SQLERRD(2)
SQLER2
Contains the last four characters of a CPD diagnostic message if the SQL code is less than 0.1

For a CALL statement, SQLERRD(2) contains the number of result sets.

For an OPEN statement, if the cursor is insensitive to changes, SQLERRD(2) contains the actual number of rows in the result set. If the cursor is sensitive to changes, SQLERRD(2) contains an estimated number of rows in the result set.

SQLERRD(3)
sqlerrd[2]
SQLERRD(3)
SQLER3
For a CONNECT for status statement, SQLERRD(3) contains information about the connection status. See CONNECT (type 2) for more information.

For INSERT, MERGE, UPDATE, REFRESH, and DELETE, shows the number of rows affected.

Start of changeFor a TRUNCATE statement, the value will be -1.End of change

For a FETCH statement, SQLERRD(3) contains the number of rows fetched.

For the PREPARE statement, contains the estimated number of rows selected. If the number of rows is greater than 2 147 483 647, then 2 147 483 647 is returned.

SQLERRD(4)
sqlerrd[3]
SQLERRD(4)
SQLER4
For the PREPARE statement, contains a relative number estimate of the resources required for every execution. This number varies depending on the current availability of indexes, file sizes, CPU model, etc. It is an estimated cost for the access plan chosen by the Db2 for i Query Optimizer.

For a CONNECT and SET CONNECTION statement, SQLERRD(4) contains the type of conversation used and whether or not committable updates can be performed. See CONNECT (type 2) for more information.

For a CALL statement, SQLERRD(4) contains the message key of the error that caused the procedure to fail. The QMHRTVPM API can be used to return the message description for the message key.

For a trigger error in a DELETE, INSERT MERGE, or UPDATE statement, SQLERRD(4) contains the message key of the error that was signaled from the trigger program. The QMHRTVPM API can be used to return the message description for the message key.

Start of changeFor a FETCH statement, if the result row does not contain a LOB, SQLERRD(4) contains the length of the row(s) retrieved.End of change

Start of changeFor an OPEN statement, if the result row does not contain a LOB, SQLERRD(4) contains the length of a result row.End of change

SQLERRD(5)
sqlerrd[4]
SQLERRD(5)
SQLER5

For a CONNECT or SET CONNECTION statement, SQLERRD(5) contains:

  • -1 if the connection is unconnected
  • 0 if the connection is local
  • 1 if the connection is remote

For a DELETE, INSERT, MERGE, or UPDATE statement, shows the number of rows affected by referential constraints and triggers.

For an EXECUTE IMMEDIATE or PREPARE statement, may contain the position of a syntax error.

For a multiple-row FETCH statement, SQLERRD(5) contains +100 if the last row currently in the table has been fetched.

For a PREPARE statement, SQLERRD(5) contains the number of parameter markers in the prepared statement.

SQLERRD(6)
sqlerrd[5]
SQLERRD(6)
SQLER6
Contains the SQL completion message identifier when the SQLCODE is 0.

In all other cases, it is undefined.

Note:
1
SQLERRD(1) and SQLERRD(2) are set only if appropriate and only if the current server is Db2 for i.
Table 4. SQLERRMC Replacement Text for CONNECT and SET CONNECTION
Description Data type
Relational Database Name CHAR(18)
Product Identification (same as SQLERRP) CHAR(8)
User ID of the server job CHAR(10)
Connection method (*DUW or *RUW) CHAR(10)
DDM server class name
QAS
Db2 for i
QDB2
DB2 for z/OS
QDB2/6000
DB2 for AIX®
QDB2/HPUX
DB2 for HP-UX**
QDB2/LINUX
DB2 for Linux®
QDB2/NT
DB2 for Windows** NT, 2000, and XP
QDB2/SUN
DB2 for SUN** Solaris**
QSQLDS/VM
DB2 Server for VM
QSQLDS/VSE
DB2 Server for VSE
CHAR(10)
Connection type (same as SQLERRD(4)) SMALLINT