SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual—523725-004
3-60
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. */
 ...
}
...










