Notes

SQLSTATE values: Any valid SQLSTATE value can be used in the SIGNAL statement. However, it is recommended that programmers define new SQLSTATEs based on ranges reserved for applications. This prevents the unintentional use of an SQLSTATE value that might be defined by the database manager in a future release.

SQLSTATE values are comprised of a two-character class code value, followed by a three-character subclass code value. Class code values represent classes of successful and unsuccessful execution conditions.

For more information about SQLSTATEs, see the SQL Messages and Codes book in the iSeries Information Center.

Assignment: When the SIGNAL statement is executed, the value of each of the specified string-constants, SQL-parameter-names, and SQL-variable-names is assigned (using storage assignment) to the corresponding condition-information-item. For details on the assignment rules, see Assignments and comparisons. For details on the maximum length of specific condition-information-items, see GET DIAGNOSTICS.

Processing a SIGNAL statement: When a SIGNAL statement is issued, the SQLCODE returned in the SQLCA is based on the SQLSTATE value as follows:

If the SQLSTATE or condition indicates that an exception (SQLSTATE class other than '01' or '02') is signalled,

If the SQLSTATE or condition indicates that a warning (SQLSTATE class '01') or not found (SQLSTATE class '02') is signalled,

Affects on the diagnostic area: The SIGNAL statement starts with a clear diagnostics area and sets the RETURNED_SQLSTATE to reflect the SQLSTATE or condition name specified.