Start of change

SQLCODE_INFO table function

The SQLCODE_INFO table function returns the SQL message associated with the specified SQLCODE value.

Every non-zero SQLCODE returned by a Db2 for i operation corresponds to a message in the QSQLMSG message file. This table function returns the message identifier and message text that is associated with a specific SQLCODE.

Authorization: See Note below.

Read syntax diagramSkip visual syntax diagram SQLCODE_INFO ( P_SQLCODE =>  sqlcode )
The schema is SYSTOOLS.
sqlcode
An integer value that represents a positive (warning) or negative (error) SQLCODE.
The result of the function is a table containing one row for a recognized SQLCODE value. If an unsupported SQLCODE value is provided, no row is returned. The columns of the result table are described in the following table. The result columns are nullable.
Table 1. SQLCODE_INFO table function
Column Name Data Type Description
MESSAGE_ID CHAR(7) The message identifier that corresponds to the SQLCODE.
MESSAGE_TEXT VARGRAPHIC(132) CCSID 1200 The text of the message.
MESSAGE_SECOND_LEVEL_TEXT VARGRAPHIC(3000) CCSID 1200 The second-level message text of the message.

Note

This function is provided in the SYSTOOLS schema as an example of finding a specific message in a message file. Similar to other Db2® for i provided tools within SYSTOOLS, the SQL source can be extracted and used as a model for building similar helper functions, or to create a customized version within a user-specified schema.

Services provided in SYSTOOLS have authorization requirements that are determined by the interfaces used to implement the service. To understand the authority requirements, extract the SQL for the service and examine the implementation.

Example

Return the message information for SQLCODE -204.
SELECT * FROM TABLE(SYSTOOLS.SQLCODE_INFO(-204));
End of change