Returns multiple information items combined into one string.
If the
GET DIAGNOSTICS statement is specified in an SQL function, SQL procedure,
or trigger, the GET DIAGNOSTICS statement must be the first statement specified
in the handler that will handle the error.
If information is desired
about a warning,
- If a handler will get control for the warning condition, the GET DIAGNOSTICS
statement must be the first statement specified in that handler.
- If a handler will not get control for the warning condition, the GET DIAGNOSTICS
statement must be the next statement executed after that previous statement.
- SQL-variable-name-4 or SQL-parameter-name-4
- Identifies a variable described in the program in accordance with the
rules for declaring SQL variables or SQL parameters. The data type of the
SQL variable or SQL parameter must be VARCHAR. If the length of SQL-variable-name-4 or SQL-parameter-name-4 is not sufficient to hold the full
returned diagnostic string, the string is truncated, a warning is returned
(SQLSTATE 01004) and the GET_DIAGNOSTICS_DIAGNOSTICS item of the diagnostics
area is updated with the details of this condition.
- ALL
- Indicates that all diagnostic items that are set for the last SQL statement
executed should be combined into one string. The format of the string is a
semicolon separated list of all of the available diagnostic information in
the form:
item-name=character-form-of-the-item-value;
The character form of a positive numeric value will not contain a leading
plus sign (+) unless the item is RETURNED_SQLCODE. In this case, a leading
plus sign (+) is added. For example:
NUMBER=1;RETURNED_SQLSTATE=02000;DB2_RETURNED_SQLCODE=+100;
Only items that contain diagnostic information are included in the
string.
- STATEMENT
- Indicates that all statment-information-item diagnostic items
that contain diagnostic information for the last SQL statement executed should
be combined into one string. The format is the same as described above for
ALL.
- CONDITION
- Indicates that condition-information-item diagnostic items
that contain diagnostic information for the last SQL statement executed should
be combined into one string. If SQL-variable-name-5 or SQL-parameter-name-5 or integer is specified, then the format is the same as described
above for the ALL option. If SQL-variable-name-5 or SQL-parameter-name-5 or integer is not specified, then the format includes a condition
number entry at the beginning of the information for that condition in the
form:
CONDITION_NUMBER=X;item-name=character-form-of-the-item-value;
where X is the number of the condition. For example:
CONDITION_NUMBER=1;RETURNED_SQLSTATE=02000;RETURNED_SQLCODE=+100;
CONDITION_NUMBER=2;RETURNED_SQLSTATE=01004;
- CONNECTION
- Indicates that connection-information-item diagnostic items
that contain diagnostic information for the last SQL statement executed should
be combined into one string. If SQL-variable-name-5 or SQL-parameter-name-5 or integer is specified, then the format is the same as described
above for ALL. If SQL-variable-name-5 or SQL-parameter-name-5 or integer is not specified, then the format includes a connection
number entry at the beginning of the information for that condition in the
form:
CONNECTION_NUMBER=X;item-name=character-form-of-the-item-value;
where X is the number of the condition. For example:
CONNECTION_NUMBER=1;CONNECTION_NAME=SVL1;DB2_PRODUCT_ID=DSN07010;
- SQL-variable-name-5 or SQL-parameter-name-5 or integer
- Identifies the diagnostic for which ALL CONDITION or ALL CONNECTION
information is requested. The SQL variable or SQL parameter specified must
be described in the program in accordance with the rules for declaring numeric
SQL variables or SQL parameters. The value specified must not be less than
one or greater than the number of available diagnostics.