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.
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.
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 this_value greater than 3000.
Disable the breakpoint and execute the procedure.
Click the breakpoint so that it turns gray (disabled).
Press F5 to complete execution of the procedure.
The Interactive SQL window appears again. It shows the correct results.
The hypothesis is confirmed. The problem is that the top_value is not initialized.
From the Mode menu, choose Design mode.
Immediately after the line containing the following text
Create a new line that initializes the top_value variable:
SET top_value = 0;
Press Ctrl+S to save the modified procedure.
Execute the procedure again, and confirm that Interactive SQL displays the correct results.
You have now completed the lesson. Close any open Interactive SQL windows.