SQL/MX 3.2 Reference Manual (H06.25+, J06.14+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
3-59
Considerations for GET DIAGNOSTICS
Considerations for GET DIAGNOSTICS
Processing Condition Items in the Diagnostics Area
You can retrieve:
The number of filled-in condition items
Fields for a specific condition item
You can use the number of filled-in condition items to construct a loop to process
individual items.
Writing a Log of Exception Conditions
You can retrieve the message text of the exception condition for SQLSTATE and
SQLCODE. To provide a log of exception conditions, write the SQLSTATE and
SQLCODE values, along with the message text, to a file to be used for future
reference.
C Examples of GET DIAGNOSTICS
Use the diagnostics area to get information about exception conditions:
...
EXEC SQL GET DIAGNOSTICS :hv_num = NUMBER,
...;
for (i = 1; i <= hv_num; i++) {
EXEC SQL GET DIAGNOSTICS EXCEPTION :i
:hv_sqlstate = RETURNED_SQLSTATE,
:hv_sqlcode = SQLCODE,
:hv_msgtext = MESSAGE_TEXT,
...;
/* Write to the exception condition log file. */
...
/* Process the diagnostic area values. */
...
}
...
SQLCODE* Exact numeric, scale 0. SQLCODE value of this
condition.
ROW_NUMBER* Exact numeric, scale 0. Identifies the row number in
error during rowset operations.
* The condition item is an SQL/MX extension.
Table 3-4. GET DIAGNOSTICS Condition Items (page3of3)
Condition Item Name Data Type and Description