GET DIAGNOSTICS statement

The GET DIAGNOSTICS statement obtains information about the previous SQL statement that was executed.

See GET DIAGNOSTICS statement.

When you need to specify a variable in a GET DIAGNOSTICS statement that is used within an SQL routine, you would use either SQL-variable-name or SQL-parameter-name. In an embedded GET DIAGNOSTICS statement, you would use a host-variable. You can replace the instances of host-variable in the description of GET DIAGNOSTICS statement with SQL-variable-name or SQL-parameter-name.

Effects of the statement: The GET DIAGNOSTICS statement does not change the contents of the diagnostics area except for DB2_GET_DIAGNOSTICS_DIAGNOSTICS.

Considerations for the SQLSTATE and SQLCODE SQL variables: The GET DIAGNOSTICS statement does not change the value of the SQLSTATE and SQLCODE SQL variables.

The stacked diagnostics area: The stacked diagnostics area is only available within a handler in a native SQL procedure and non-inline SQL functions.