Debugging stored procedures by using the Unified Debugger

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:

  1. Set up the Unified Debugger by performing the following steps:
    1. 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.
    2. Define the debug mode characteristics for the stored procedure that you want to debug by completing one of the following actions:
      • For native SQL procedures, define the procedures 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 to build the SQL procedure with the BUILD_DEBUG option.
      • Start of changeIf you deploy the procedure with Db2 Developer Extension, specify Enable debugging in the deployment options.End of change
      • For Java stored procedures, define the procedures with the ALLOW DEBUG MODE option, select an appropriate WLM environment for Java debugging, and compile the Java code with the -G option.
    3. Grant the DEBUGSESSION privilege to the user who runs the debug client.
  2. Include breakpoints in your routines or executable files.
  3. Follow the instructions for debugging stored procedures in the information for IBM® Data Studio.