Exercise 1.4: Debugging the stored procedure

Before you begin, you must complete Exercise 1.3: Creating and building an SQL stored procedure.

The workbench includes an integrated SQL stored procedure debugger. By stepping through your code while 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 only debugging SQL stored procedures, with some further limitations depending on your operating system and DB2(R) Universal Database(TM) version. See the SQL stored procedure debugger help topics in the information center for more details.

To debug the stored procedure:

  1. In the editor, click in the left vertical margin to set line breakpoints.
  2. In the Data Definition view, right-click the stored procedure, and select Debug. The Debug window opens.
  3. In the Configurations list, select the SPEmployee stored procedure.
  4. Click Edit. The Stored Procedure Arguments window opens.
  5. 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.

  6. Click OK in the Stored Procedure Arguments window, then click Debug in the Debug window.
  7. Click OK when you are prompted to switch to the Debug perspective.

    The stored procedure opens in the Debug perspective.

  8. From the Run menu, select Resume, Step into, or Step over to run in debug mode.
  9. Continue running in debug mode until the stored procedure returns the desired results, then close the Debug perspective and switch back to the Data perspective.

Now you are ready to begin Exercise 1.5: Running the SQL stored procedure.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.