The GET DIAGNOSTICS statement

This section briefly summarizes how to use the GET DIAGNOSTICS statement within the program. For a full description of the GET DIAGNOSTICS statement, see the HCL OneDB™ Guide to SQL: Syntax.

The GET DIAGNOSTICS statement returns information that is held in the fields of the diagnostics area. The diagnostics area is an internal structure that the database server updates after it executes an SQL statement. Each application has one diagnostics area. Although GET DIAGNOSTICS accesses the diagnostics area, it never changes the contents of this area.

To access a field in the diagnostics area, supply a host variable to hold the value and the field keyword to specify the field that you want to access:
:host_var = FIELD_NAME

Make sure that the data types of the host variable and the diagnostics field are compatible.

The fields of the diagnostics area fall into two categories:
  • Statement information describes the overall result of the SQL statement, in particular the number of rows that it has modified and the number of exceptions that result.
  • Exception information describes individual exceptions that result from the SQL statement.