You can use the Unified Debugger to remotely debug native
SQL procedures, external SQL procedures, and Java stored procedures that execute on DB2® for z/OS® servers. The Unified Debugger also supports
debugging nested stored procedure calls.
About this task
With the Unified Debugger, you can observe the execution
of the procedure code, set breakpoints for lines, and view or modify
variable values.
Procedure
To debug stored procedures by using the Unified Debugger:
- Set up the Unified Debugger by performing the following steps:
Ensure that job DSNTIJRT successfully created the stored procedures
that provide server support for the Unified Debugger. This job is
run during the installation and migration process. The stored procedures
that this job creates must run in WLM environments. Recommendation: Initially, define and use
the DB2 core WLM environment
DSNWLM_GENERAL to run the SYSPROC.DBG_RUNSESSIONMANAGER stored procedure
and core WLM environment DSNWLM_DEBUGGER to run the other stored procedures
for Unified debugger.

- Define the debug mode characteristics for the stored
procedure that you want to debug by completing one of the following
actions:
- For a native SQL procedure, define the procedure with the ALLOW
DEBUG MODE option and the WLM ENVIRONMENT FOR DEBUG MODE option. If
the procedure already exists, you can use the ALTER PROCEDURE statement
to specify these options.
- For an external SQL procedure, use DSNTPSMP or IBM® Data Studio to build the SQL procedure with the
BUILD_DEBUG option.
- For a Java stored procedure,
define the procedure with the ALLOW DEBUG MODE option, select an appropriate
WLM environment for Java debugging,
and compile the Java code with
the -G option.
- Grant the DEBUGSESSION privilege to the user who runs
the debug client.
- Include breakpoints in your routines or executable files.
- Follow the instructions for debugging stored procedures in the information for IBM Data Studio.