To diagnose the bug in the procedure, set breakpoints in the procedure and step through the code, watching the value of variables as the procedure is executed.
Here, you set a breakpoint at the first executable statement in the procedure.
Choose Mode » Debug.
In the right pane, double-click Debugger_Tutorial (GROUPO).
In the right pane, locate the following statement:
To add a breakpoint, click the vertical gray area to the left of the statement. The breakpoint appears as a red circle.
In the left pane, right-click Debugger_Tutorial (GROUPO) and choose Execute From Interactive SQL.
In the Connections tab of Sybase Central, a yellow arrow indicating the breakpoint appears.
In the Debugger Details window, click the Local tab to display a list of local variables in the procedure together with their current value and data type. The top_company, top_value, this_value, and this_company variables are all uninitialized and are therefore NULL.
Press F11 to scroll through the procedure. The value of the variables changes when you reach the following line:
IF this_value > top_value THEN
Press F11 once more to determine which branch the execution takes. The yellow arrow moves back to the following text:
IF test did not return true. The test failed because a comparison of any value to NULL returns NULL. A value of NULL fails the
test and the code inside the
END IF statement is not executed.
At this point, you may realize that the problem is the fact that top_value is not initialized.
Discuss this page in DocCommentXchange.
|Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0|