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 debug.
- Locate one of the following local session manager start files
in your Developer Workbench 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, 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 Debug window
opens.
- In the Configurations list, select the schemaname.SPEmployee
stored procedure.
- If the Procedure field is blank, click Browse.
The Stored Procedures window opens. Select schemaname.SPEmployee
and click OK.
- To the right of the Arguments field, click Edit. The Stored Procedure Arguments window opens.
- In the Value field for DEPT, 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 in the Stored Procedure Arguments
window, and click Debug in the Debug window. 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 stored procedure returns
the required results.