Embedded SQL statements return codes in the SQLCODE, SQLWARN, and SQLSTATE fields of the SQLCA structure. This structure is defined in an SQLCA include file. (For more information about the SQLCA structure and SQLCA include file, see DB2 Application Development Guide.)
DB2 CLI calls return SQLCODE and SQLSTATE values that you can retrieve using the SQLError function. (For more information about retrieving error information with the SQLError function, see CLI Guide and Reference.)
An SQLCODE value of 0 means that the statement ran successfully (with possible warning conditions). A positive SQLCODE value means that the statement was successfully run but with a warning. (Embedded SQL statements return the warning associated with 0 or positive SQLCODE values in the SQLWARN field.) A negative SQLCODE value means that an error condition occurred.
DB2 associates a message with each SQLCODE value. If a DB2 extender UDF encounters a warning or error condition, it passes associated information to DB2 for inclusion in the SQLCODE message.
SQLSTATE values contains codes that supplement the SQLCODE messages. See SQLSTATE codes for a description of each SQLSTATE code returned by the DB2 extenders.
Embedded SQL statements and DB2 CLI calls that invoke DB2 extender UDFs might return SQLCODE messages and SQLSTATE values that are unique to these UDFs, but DB2 returns these values in the same way as it does for other embedded SQL statements or other DB2 CLI calls. Thus, the way you access these values is the same as for embedded SQL statements or DB2 CLI calls that do not start DB2 extender UDFs.
See SQLSTATE codes for the SQLSTATE values and the message number of associated messages that can be returned by the extenders. See Messages for information about each message.