Skip to Content

Debugging Stored Procedures

test
0 %
Debugging Stored Procedures
Details

Debugging Stored Procedures

July 17, 2020
Created by
September 5, 2016
Leveraging SQLScript in stored procedures, user-defined functions, and user-defined libraries.

You will learn

  • How to debug a procedure using the SQLScript debugger

Prerequisites

The debugging shown in this tutorial includes setting breakpoints, evaluating expressions and intermediate results.


Step 1: Start debugger

Go to the Database Explorer page and right-click on the procedure called get_po_header_data and choose Open for Debugging.

DBX

Make sure the configuration is set as shown here and click OK.

apply
Log on to answer question
Step 2: Set breakpoints

Set breakpoints at the lines shown here by simply clicking on the line number.

breakpoints

Right click on the procedure and choose Generate Call Statement

invoke

A new SQL tab will be opened. Click on the Run button.

SQL tab
Log on to answer question
Step 3: View debugger pane

Execution of the procedure has started, and a debugger pane is now visible which is displayed on the right. You can see all of the variables and parameters for this procedure. You might notice that this pane is currently not showing the intermediate table variables at this point.

execute procedure
Log on to answer question
Step 4: Use step over

Click the Step Over button.

step over

You will notice that execution has continued to the next statement. In the debugger pane, a new local variable has been added. This is because it is not defined explicitly and will be implicitly declared at runtime during first usage.

next step

To see the data for this intermediate table variable, select it and click Display Content

display content

A new window is then opened showing the data in the table. Review the data and close the window by clicking Close

review data
Log on to answer question
Step 5: View expression editor

Click the Expression tab and click + button.

toggle expression editor

In the following window, enter a SELECT statement as shown here and hit Add.

select statement

You will notice the expression is then added to the “Expressions” section.

expressions
Log on to answer question
Step 6: View expressions

Select the expression and click Display Content.

display content

Review the results and close the window.

review results
Log on to answer question
Step 7: Check output

Once again click the Step Over button. Notice the next intermediate table variables is also added. You can review the data in this table as well.

step over

Continue to step through the code and when execution stops at the END statement of the procedure, display the contents of the output parameter the same way you did for the intermediate table variables. Finally, close the window by clicking the Close.

continue steps
Log on to answer question
Step 8: Resume execution

Click the Resume button.

resume

Execution of the procedure is now completed. Return to the SQL tab and check the results.

results
Log on to answer question

Next Steps

Back to top