Contents Index Step through source code Working with breakpoints

ASA SQL User's Guide
  Debugging Logic in the Database
    Tutorial: Getting started with the debugger
      Lesson 3: Debug a Java class

Inspect and modify variables

In this lesson you inspect the values of both local variables (declared in a method) and class static variables in the debugger.

Inspecting local variables 

You can inspect the values of local variables in a method as you step through the code, to better understand what is happening. You must have compiled the class with the javac -g option to do this.

To inspect and modify the value of a variable

  1. Set a breakpoint at the first line of the JDBCExamples.Query method. This line is as follows:

    int max_price = 0
  2. In Interactive SQL, enter the following statement again to execute the method:

    SELECT JDBCExamples.Query()

    The query executes only as far as the breakpoint.

  3. Press F10 to step to the next line. The max_price variable has now been declared and initialized to zero.

  4. In the Local tab list, double-click the Value column entry for max_price, and type in 45 to change the value of max_price to 45.

    The value 45 is larger than any other price. Instead of returning 24, the query will now return 45 as the maximum price.

  5. Press F10 repeatedly to step through the code. As you do so, the values of the variables appear in the Local tab list. Step through until the stmt and result variables have values.

  6. Expand the result object by clicking the icon next to it, or setting the cursor on the line and pressing Enter. This displays the values of the fields in the object.

  7. When you have experimented with inspecting and modifying variables, press F5 to complete the execution of the query and finish the tutorial.

Inspecting static variables 

In addition to local variables, you can display class-level variables (static variables) in the debugger Statics tab, and watch their values in the Watch tab. For more information, see the debugger online Help.


Contents Index Step through source code Working with breakpoints