GET DIAGNOSTICS
You can use the Db2 SQL statement GET DIAGNOSTICS in conjunctions with Jopaz to capture diagnostic information from the previous SQL statement during execution. This feature is only supported for static SQL using SQLJ. This means, it is only available when the JPZS<SSID> compilation job is used for compilation in combination with the COMOPTS configuration file. This file contains the compiler option -sqlj.
Compiler
To compile the GET DIAGNOSTICS statement successfully, you must add the compiler option -sqljdiag to the jopaz.compiler.options property in the COMOPTS file.
Runtime
The jopaz.sqlj.get_diagnostics runtime property, which is set in the RUNOPT configuration file, determines the behavior of the GET DIAGNOSTICS statement during runtime. Since the GET DIAGNOSTICS statement is not natively supported in Java on z/OS, Jopaz provides the following alternative options to handle diagnostics appropriately in the program logic:
jopaz.sqlj.get_diagnostics=0
Returns with an internal error and stops execution.
Internal error: GET DIAGNOSTIC Not Supported
jopaz.sqlj.get_diagnostics=1
The GET DIAGNOSTICS function is not executed. A warning message is issued, and program execution continues.
DIAGNOSTIC IS NOT SUPPORTED and no statement was executed for it!
jopaz.sqlj.get_diagnostics=2
The GET DIAGNOSTICS function is not executed. An info message is displayed later and DSNTIAR is called.
GET DIAGNOSTICS cannot run and will call DSNTIAR instead!
The recommended approach is jopaz.sqlj.get_diagnostics=2. This configuration allows the program to call DSNTIAR instead of GET DIAGNOSTICS to collect diagnostic information.
Note:
All diagnostic fields (such as NUMBER, DB2_RETURNED_SQLCODE, RETURNED_SQLSTATE) contain only initialized or empty values since GET DIAGNOSTICS is not really executed, and these fields cannot be filled.
To view the output of DSNTIAR, the additional runtime option jopaz.tracelevel=256 must be enabled. This option displays the DSNTIAR output in STDOUT. If this trace level is not enabled, the DSNTIAR output will not be displayed in STDOUT.