The GET DIAGNOSTICS statement retrieves exception or completion condition information from a Diagnostics Area (for information, see Diagnostics Area).
Note: CURRENT and STACKED are optional choices for specifying which diagnostics area to use.
CONDITION followed by an integer is an optional specificiation for which condition area to use. If you do not specify CONDITION, a default of CONDITION 1 is used (see the description following the syntax).
►►─ GET ─┬───────────┬─ DIAGNOSTICS ──────────────────────────────────────────► ├─ CURRENT ─┤ └─ STACKED ─┘ ►─┬──────────────────────────────────┬─ diagnostic-info-items ───────────────►◄ └─ CONDITION ─ integer-expression ─┘
Expansion of Where diagnostic-info-items are defined as
┌─ , ───────────────────────┐ ├──▼─┬─ statement-info-item ─┬─┴───────────────────────────────────────────────┤ └─ condition-info-item ─┘
Expansion of Where statement-info-item is defined as
┌─ , ────────────────────────────────────────────────┐ ├──▼─┬─ SQL-variable-name ──┬─statement-info-item-name ─┴──────────────────────┤ └─ SQL-parameter-name ─┘
Expansion of Where statement-info-item-name is defined as
├──┬─ NUMBER ─┬────────────────────────────────────────────────────────────────┤ └─ MORE ───┘
Expansion of Where condition-info-item is defined as
┌─ , ───────────────────────────────────────────┐ ├──▼─┬─ SQL-variable-name ──┬─cond-info-item-name ─┴───────────────────────────┤ └─ SQL-parameter-name ─┘
Expansion of Where cond-info-item-name is defined as
├──┬─ CONDITION_NUMBER ─────┬──────────────────────────────────────────────────┤ ├─ MESSAGE_LENGTH ───────┤ ├─ MESSAGE_TEXT ─────────┤ ├─ RETURNED_SQLSTATE ────┤ └─ CONDITION_IDENTIFIER ─┘
(Optional) Specifying CURRENT (or omitting this optional specification), to indicate which diagnostics area to use, causes information to be retrieved on the SQL error (or other condition) generated by the SQL statement that was just executed.
(Optional) Specifying STACKED inside an error handler retrieves the Diagnostics Area that is related to the condition that caused the handler to be executed. This original Diagnostics Area has been pushed in order to supply an empty current Diagnostics Area for use by any conditions that can be caused by the error handler itself.
(Optional) CONDITION followed by an integer that can range in value from one (1) to the number of condition areas available, specifies which condition area to retrieve. Within each Diagnostics Area lies a stack of condition information areas, allowing each Diagnostics Area to store information related to any sequence of errors or conditions that could have occurred during the execution of a single statement.
The number of condition areas available is specified by using the Multi-User startup option SQL_COND_INFO_AREAS (for Multi-User startup option information, see the CA Datacom/DB Database and System Administration Guide).
If you do not specify CONDITION, the default is CONDITION 1, which specifies using the most recent error condition, that is, the error condition that occurred during the last non-diagnostics related SQL statement that executed.
The diagnostic-info-items variable specifies the information you want to store and where to store it.
The statement-info-item contains information about the statement that was executing when the condition occurred.
A statement-info-item-name (the data type listed in parentheses must be compatible with the data type of the variable or parameter into which the value is being stored) can be one of the following:
NUMBER (SMALLINT) NUMBER indicates the number of condition areas that are in use.
MORE (CHAR(1)) A letter Y (for YES) indicates that more conditions than condition areas occurred.
The condition-info-item variable contains information about the condition that occurred.
A cond-info-item-name (the data type listed in parentheses must be compatible with the data type of the variable or parameter into which the value is being stored) can be one of the following:
CONDITION_NUMBER (SMALLINT) indicates the condition for which you want to retrieve information. Specifying 1 (a number one) indicates the most recent condition, a 2 specifies the second most recent condition, and so on.
MESSAGE_LENGTH (SMALLINT) indicates the length of the message text information item.
MESSAGE_TEXT (VARCHAR(128)) indicates the text of the error message or signal condition.
RETURNED_SQLSTATE (CHAR(5)) indicates the condition that occurred.
CONDITION_IDENTIFIER (VARCHAR(128)) gives the name, if one was signaled, of a named condition.
|
Copyright © 2014 CA.
All rights reserved.
|
|