EXCEPTION Clause
Element | Description | Restrictions | Syntax |
---|---|---|---|
exception_num | Number of exceptions | Integer in range 1 to 35,000 |
Literal Number |
exception_var | Variable storing exception_num | Must be SMALLINT or INT | Language specific |
information | Host variable to receive the value of a specified exception field | Data type must match that of the specified field | Language specific |
The exception_num literal indicates one of the exception values from the number of exceptions that the NUMBER field in the Statement clause returns.
When retrieving exception information, GET DIAGNOSTICS writes the values of each of the seven fields into corresponding host variables. These fields are located in the diagnostics area and are derived from an exception raised by the most recent SQL statement.
Field Name Keyword | Field Data Type | Field Contents | ESQL/C Host Variable Data Type |
---|---|---|---|
RETURNED_SQLSTATE | Character | SQLSTATE value | char[6] |
INFORMIX_SQLCODE | Integer | Informix®-specific status code | int4 |
CLASS_ORIGIN | Character | String | char[255] |
SUBCLASS_ORIGIN | Character | String | char[255] |
MESSAGE_TEXT | Character | String | char[255] |
MESSAGE_LENGTH | Integer | Numeric value | int |
SERVER_NAME | Character | String | char[255] |
CONNECTION_NAME | Character | String | char[255] |
The application specifies the exception by number, using
either an unsigned integer or an integer host variable (an exact numeric
with a scale of 0). An exception with a value of 1
corresponds
to the SQLSTATE value set by the most recent SQL statement
other than GET DIAGNOSTICS. The association between other exception
numbers and other exceptions raised by that SQL statement
is undefined. Thus, no set order exists in which the diagnostic area
can be filled with exception values. You always get at least one exception,
even if the SQLSTATE value indicates success.
If an error occurs within the GET DIAGNOSTICS statement (that is, if an invalid exception number is requested), the Informix® internal SQLCODE and SQLSTATE variables are set to the value of that exception. In addition, the GET DIAGNOSTICS fields are undefined.