The workbench includes an integrated stored procedure debugger.
By stepping through your code while you are running in debug mode
and viewing the results, you can discover problems with your stored
procedure and make the necessary changes.
The stored procedure debugger supports debugging SQL or
Java stored procedures, with some limitations depending on your operating
system and DB2 version. See the stored procedure debugger help topics
in the information center for more details.
To debug the stored
procedure:
- Set up the debugger. Before you debug, you must
set up the server and the session manager. The session manager connects
the debugger user interface to the DB2 server and must be running
before the debug session can start.
- Set
up the server for debugging.
- Locate one of the following local session manager start
files in the workbench's root installation directory:
For Windows: db2dbgm.bat
For Linux: db2dbgm.000
- Modify the appropriate file as needed to reflect your
install path, CLASSPATH, and port settings.
- Run the file to start the local (client) session manager.
- Note the IP address and port of the session manager
daemon in the command window that opens when you run the file, or
in a command window that is already open. You must enter
this information into the DB2 Stored Procedure Debugger Preferences
window.
- Click , and expand the Run/Debug node.
- Click DB2 Stored Procedure Debugger.
- In the right panel, select Use already running
session manager, and then enter the IP address and port
number for the session manager.
- Optional: Modify session timeout and other settings.
- Click OK to save your settings
and close the Preferences window.
- In the routine editor, double-click in the left vertical
margin to set line breakpoints.
- In the Data Project Explorer view, right-click the stored
procedure, and select Debug. The Specify
Parameter Values window opens.
- In the Value field, type D11. D11 is the ID for a department (EMPLOYEE.WORKDEPT) in the EMPLOYEE
table. When you enter this value, the stored procedure will return
rows that match this department ID.
- Click OK. A prompt
asks if you want to switch to the Debug perspective. Click Yes.
- From the Run menu, select Resume, Step
into, or Step over to run in debug
mode.
- Continue running in debug mode until the results appear
in the SQL Results view.
You can return to the Data perspective by clicking the

button in the top-right corner of the workbench and selecting
Data.