Running and Debugging Functions and Procedures |
You can use SQL Developer to run and debug PL/SQL functions and procedures.
To run a function or procedure, click its name in the Connections navigator; then either right-click and select Run, or click the Edit icon and then click the Run icon above its source listing.
To debug a function or procedure, click its name in the Connections navigator. If the procedure in its current form has not already been compiled for debug, right-click and select Compile for Debug. Then click the Edit icon and click the Debug icon above its source listing.
In both cases, a code editing window is displayed. The following figure shows the code editing window being used to debug a procedure named LIST_A_RATING2, which is used for tutorial purposes in Debugging a PL/SQL Procedure.
The code editing window has the following tabs:
The Source tab displays a toolbar and the text of the function or procedure, which you can edit. You can set and unset breakpoints for debugging by clicking to the left of the thin vertical line beside each statement with which you want to associate a breakpoint. (When a breakpoint is set, a red circle is displayed.)
The Privileges tab displays, for each privilege associated with the function or procedure, the grantor and grantee, the object name, and whether the grantee can grant the privilege to other users.
The Dependencies tab shows any objects that this function or procedure references, and any objects that reference this function or procedure.
The Source tab toolbar has the icons shown in the following figure.
Run starts normal execution of the function or procedure, and displays the results in the Running - Log tab.
Debug starts execution of the function or procedure in debug mode, and displays the Debugging - Log tab, which includes the debugging toolbar for controlling the execution.
Compile performs a PL/SQL compilation of the function or procedure.
Compile for Debug performs a PL/SQL compilation of the function or procedure so that it can be debugged.
The Debugging - Log tab under the code text area contains the debugging toolbar and informational messages. The debugging toolbar has the icons shown in the following figure.
Find Execution Point goes to the next execution point.
Resume continues execution.
Step Over bypasses the next method and goes to the next statement after the method.
Step Into goes to the first statement in the next method.
Step Out leaves the current method and goes to the next statement.
Step to End of Method goes to the last statement of the current method.
Pause halts execution but does not exit, thus allowing you to resume execution.
Terminate halts and exits the execution. You cannot resume execution from this point; instead, to start running or debugging from the beginning of the function or procedure, click the Run or Debug icon in the Source tab toolbar.
Garbage Collection removes invalid objects from the cache in favor of more frequently accessed and more valid objects.
The Breakpoints tab under the code text area displays breakpoints, both system-defined and user-defined.
The Smart Data tab under the code text area displays information about variables associated with breakpoints.
The Data tab under the code text area displays information about all variables.
The Watches tab under the code text area displays information about watchpoints.
For more information about developing, compiling, and using PL/SQL functions and procedures, see Subprograms and Packages: Usage Information.
Related Topics
Using Snippets to Insert Code Fragments
Run/Debug PL/SQL (dialog box)
Debugging a PL/SQL Procedure (tutorial)