Debugging a Stored Function
Last modified: October 30, 2023
This example shows how to debug a stored function in dbForge Studio for Oracle. Use provided scripts to create sample objects in your test database.
Creating a Sample Function
Procedure
Use the script available in Debugging a Stored Procedure to the procedure used in the sample below.
Function
Use the script below to create the GetFirstDayOfMonth function that returns the first day of a calendar month.
CREATE OR REPLACE FUNCTION GetFirstDayOfMonth(DT DATE)
RETURN DATE
AS
BEGIN
RETURN TRUNC(DT, 'MONTH');
END;
Debugging Function
To debug the Oracle function:
- In Database Explorer, choose a test database.
- Click Procedures and then double-click the FILLSCHEDULE procedure to open it.
-
Click in the gray margin next to the SELECT statement to insert a breakpoint in the place where we call the GetFirstDayOfMonth stored function.
- Click Start Debugging, and enter the input parameters values for the procedure.
- Add the DATE_TO variable to the Watches window. This option allows you to track the value of the variable while stepping through the code. To add the variable to the Watches window, right-click the DT variable, and then select
Add Watch on the shortcut menu. The variable will appear in the Watches window.
-
Step through the code using the F11 key or the
Step Into button, or press CTRL+F5 to move directly to the breakpoint.
-
Press F11 or click
Step Into to get inside the GetFirstDayOfMonth stored function.
Note
You may ignore stepping through the function by clicking
Step Over. In this case, you will continue stepping through the stored procedure.
- Step through the GetFirstDayOfMonth function until you exit back to the stored procedure, and continue to the end.
Note
You may get back to the stored procedure code by clicking
Step Out. In this case, you will continue stepping through the stored procedure.
You may click the FILLSCHEDULE procedure in the Call Stack pane to get back to the parent code.
Note
Place the mouse pointer over a variable to see its value.
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for Oracle.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.