Contents Index Diagnose the bug Lesson 3: Debug a Java class

ASA SQL User's Guide
  Debugging Logic in the Database
    Tutorial: Getting started with the debugger
      Lesson 2: Debug a stored procedure

Confirm the diagnosis and fix the bug

You can test the hypothesis that the problem is the lack of initialization for top_value right in the debugger, without changing the procedure code.

To test the hypothesis

  1. Set a value for top_value.

    In the Local window, click the Value field of the top_value variable, and enter a value of 3000.

  2. Step through the loop again.

    Press F11 to step through the instructions to the if statement and check the values of this_value and top_value. You may have to step through several loops until you get a value of top_value greater than 3000.

  3. Disable the breakpoint and execute the procedure.

    1. Click the breakpoint so that it turns gray (disabled).

    2. Press F5 to complete execution of the procedure.

      The Interactive SQL window appears again. It shows the correct results.

      top_company top_value
      Chadwicks 8076

    The hypothesis is confirmed. The problem is that the top_value is not initialized.

To fix the bug

  1. From the Task menu, choose Design to leave Debug mode.

  2. Immediately after the line containing the following text

    open cur_this_cust;

    Create a new line that initializes the top_value variable:

    set top_value = 0;
  3. Press Ctrl+S to save the modified procedure.

  4. Execute the procedure again, and confirm that Interactive SQL displays the correct results.

You have now completed the lesson. Close down Sybase Central and any open Interactive SQL windows.


Contents Index Diagnose the bug Lesson 3: Debug a Java class