Skip to Content

SAP HANA Plugin for Microsoft Visual Studio - Debugging Procedures

Previous

SAP HANA Plugin for Microsoft Visual Studio - Debugging Procedures

By Currie

This tutorial describes how to debug stored procedures.

Details

You will learn

How to open and use the debugging features of the SAP HANA plugin for Microsoft Visual Studio.


Step 1: Open a Stored Procedure

Open the Server Explorer window. Under your server, cascade from your server to Programming Support > Stored Procedures. Right-click SYSTEM.CALCAVERAGESCORE and select Debug Procedure Debug Stored Procedure.

Select Debug Stored Procedure

The Debugging mode is activated.

Step 2: Stepping Over Lines

In debugging mode, the currently selected debugging line is indicated by the Current Line arrow to the left of the code line number.

Line Location

Stepping over lines allows you to run them individually to see if there is an error. Click the Step Over Step Over button to run the currently selected debugging line.

Step over until you have the following debugging line selected:

CALL system.calcmathaverage(MATH_AVERAGE => MATH_AVERAGE_SCORE);
Step 3: Mark a Breakpoint

To mark a line as a Breakpoint, click the left side of the code line. A red dot Breakpoint Dot appears and the line of code is added to the Breakpoints window.

Breakpoint Location

If you click the Continue Button Continue Button you will be taken to the most recent Breakpoint that you have not stepped over.

Step 4: Stepping Into the Procedure

If your line of code contains a procedure, you can Step Into Step Into the procedure. This opens up another window with the procedure selected.

Click the Step Into Step Into button. This opens the system.calcMathAverage procedure.

A new window opens with the following procedure:

CREATE OR REPLACE PROCEDURE calcMathAverage (OUT MATH_AVERAGE INT)
LANGUAGE SQLSCRIPT AS
BEGIN

	DECLARE SCORE_SUMMARY int = 0;
	DECLARE SCORE_CURRENT int = 0;
	DECLARE SCORE_COUNT int = 0;
	DECLARE CURSOR C_MATH_SCORES FOR SELECT SCORE_HISTORY FROM SYSTEM.DEMO_STUDENT_SCORE_TABLE;

	FOR cur_row AS C_MATH_SCORES
		  DO
			     SCORE_SUMMARY = SCORE_SUMMARY + cur_row.SCORE_HISTORY;
			     SCORE_COUNT = SCORE_COUNT + 1;
	END FOR;

	MATH_AVERAGE = SCORE_SUMMARY / SCORE_COUNT;
END;
Step 5: Local, Call Stack, and Watch Windows

When you step into a procedure, the Locals and Call Stack windows automatically populate. For the Locals window, values are added as each step is processed.

The Call Stack window provides a list of procedures that are currently open. The Call Stack includes the system.calcMATHAVERAGE and system.calcAVERAGESCORE procedures.

The Watch window displays any values that you have added to it. Highlight SCORE_SUMMARY / SCORE_COUNT and press Ctrl + C to copy the line. In the Watch window, underneath the Name column, click the text box and press Ctrl + V to paste the copied line. Press Enter to add the value to the watch list. As you Step Over Step Over the procedure, the Value changes from NaN to 80.

Once you are finished, Step Out Step Out of the procedure.

Step 6: Ending the Debugging Mode

To exit Debugging Mode, Step Over Step Over the remaining steps of the procedures.

You can also click the Stop Debugging Stop Debugging button.


Next Steps

Next
Back to top