Using Breakpoints

This section contains the following topics:

A breakpoint is used to suspend the execution of a PL/SQL program at the line where the breakpoint is set. You can use breakpoints to control the execution and debug the function.

  • An enabled breakpoint suspends the execution of the PL/SQL program whenever a breakpoint is encountered. When the execution hits the line of breakpoint, the execution will stop and you will be able to carry out other debug operations. Data Studio supports the following breakpoint operations:
    • Setting or adding breakpoint on a line
    • Enabling or disabling a breakpoint on a line
    • Removing a breakpoint on a line
  • A disabled breakpoint will not suspend execution of PL/SQL program.

When you run a PL/SQL program, the execution pauses at every line where you set a breakpoint. When the program execution is paused, Data Studio retrieves information about the current program state, such as the values of the program variables.

Follow the steps below to debug a PL/SQL program:

  1. Set a breakpoint at the line where PL/SQL program execution should be paused.
  2. Start the debugging session.

    When a line with a breakpoint is reached, monitor the state of the application in the debugger pane, and continue the execution.

  3. Close the debugging session.

Data Studio provides debugging options in the toolbar that helps you step through the debug objects.

Using the Breakpoints Pane

You can use the Breakpoints pane to view and manage the currently set breakpoints. From the minimized window panel, click the breakpoint option to open the Breakpoints pane.

The Breakpoints pane lists each breakpoint with the line number and the debug object name.

You can enable or disable all the breakpoints by clicking in the Breakpoints pane. You can enable, disable or delete a specific breakpoint(s) by selecting the breakpoint check box and clicking , or in the Breakpoints pane.

Double-click the required breakpoint in the Breakpoint Info column to locate the breakpoint in the PL/SQL Viewer pane.

  • Disabling a breakpoint prevents the execution from pausing at the breakpoint, but leaves the definition in place (to enable the breakpoint later).
  • Deleting a breakpoint removes it permanently.
  • The content of the Breakpoints pane can be copied to the clipboard using Alt+Y.

Setting or Adding Breakpoints on a Line

Follow the steps to set or add breakpoints on a line:

  1. Open the PL/SQL function on a line where you want to add a breakpoint.
  2. In the PL/SQL Viewer, double-click the breakpoint ruler on the left side of the Line column. The added breakpoint is indicated by an enable breakpoint sign [] in the PL/SQL Viewer.

    If the execution of the function does not break or stop the breakpoint during debugging, the breakpoint that is already set will not be validated.

Enabling or Disabling a Breakpoint on a Line

Once a breakpoint is set, you can temporarily disable it by selecting the corresponding check box in the left-side of the Breakpoints pane and clicking at the top of the Breakpoints pane. Disabled breakpoints will be grayed out [] in the PL/SQL Viewer and Breakpoints pane.

To enable a disabled breakpoint, select the corresponding breakpoint (using check box) and click .

Removing a Breakpoint on a Line

If you no longer require the breakpoint, you can remove it using the same actions used to create it.

In the PL/SQL Viewer tab, open the function in which you want to remove the breakpoint. Double-click the enable breakpoint sign [] in the PL/SQL Viewer to disable the breakpoint. The breakpoint is removed from the workspace.

You can also enable or disable breakpoints using the Breakpoints pane as explained above.

Source Code Change

During debugging, if the source code is changed after it is fetched from the server and the debugging is continued, Data Studio displays an error.

You are advised to refresh the object and perform the debug operation again.

If the source code is changed after it is fetched from the server, and if you perform the execution or debug operation with no breakpoint set, then the result of the source code at the server will be displayed on Data Studio. You are advised to refresh before performing debug or execute operation.

How to Debug a PL/SQL Program Using Breakpoints?

Follow the steps below to debug a PL/SQL program using breakpoints:

  1. Open the PL/SQL program and add a breakpoint on the line where you want to perform debug operation.

    For example:

    Line 11, 12, 13.

  2. To start debugging, click or press Ctrl+D, or right-click the selected PL/SQL program in the Object Browser and select Debug. The Debug Function/Procedure dialog box appears prompting for your input.

    If there is no input parameter, then Debug Function/Procedure dialog box will not appear.

  3. Provide your input and click OK. For varchar and date data type, provide the input value in single quotes and for numeric data type, provide the input value with or without single quotes.

    To set NULL as the parameter value, enter NULL or null.

    On clicking the Debug button, you will see an arrow pointing to the line where the breakpoint is set. The arrow indicates the line number at which execution will resume from.

    You can terminate debugging by clicking from the toolbar, or pressing F10, or select Terminate Debugging from the Debug menu. After stopping the debug operation, the execution of the function will not break for any breakpoint and the execution will be proceed normally.

    The Callstack and Variables panes are populated.

    The Variables pane shows the current value of variables. Mouse over the variable in the function/procedure also shows the current value of variables.

    You can step through the code using Step Into, Step Out or Step Over. For more details, refer to Controlling Execution .

  4. Click Continue to continue the execution till the next breakpoint (if any). The result of the executed PL/SQL program is displayed in the Result tab and the Callstack and Variables panes are cleared. You can copy the content of the Result tab, by clicking .

    To remove the breakpoint, do the following:

    • Double-click again on the breakpoint to remove it from the PL/SQL Viewer.
    • Select the breakpoint in the breakpoint check box and click in the Breakpoints pane.

Support Rearrangement of Variable Window

This feature enables the Variable Window and columns to be rearranged. You are able to arrange Variable Window to the following places:

  • Beside the SQL Assistant tab
  • Beside the SQL Terminal tab
  • Beside the Object Browser tab
  • Beside the Resultset tab
  • Beside the Breakpoints tab
  • Beside the Callstack tab
  • Below the Object Browser tab

When debugging is finished, the variable window will be minimized even if the variable window is rearranged while debugging. If variable window is rearranged as the Terminal tab or the Result tab, on completion of debugging, the tab should be minimized manually. The position of variable window is maintained after it is rearranged.

Enable/Disable System Variables

System Variables are displayed by default. You can disable the system variables whenever required.

  1. Click the red button under Variables to disable system variables.

    The button is in ON state by default.

Displaying Cached Parameter

During debug/execute a PL/SQL function or procedure, same parameter values are used for next time usage.

While executing a PL/SQL object, following window is displayed:

For the first time, parameter values are empty. Enter the value as required.

Click OK. The parameter values will be cached. Next time during the query execution/debug same parameter values will be displayed.

Once the specific connection is removed, all the parameter values in cache are cleared.

Displaying Variable in Monitor Window

Data Studio displays the variables which are being monitored in the Monitor Window while debugging.

In the Monitor Window, variables must be added in following ways:

  • Add selected variables from the Variable Window and right click the variable.
  • Select the variables from variable window and add by clicking the button in the variable window toolbar.

    If the value is changed in the variable window, the same would reflect in the monitor window if the variable is monitored and vice versa.

  • Add the variable by right clicking from the editor when debugging a function or a procedure.

The Monitor window can be dragged to anywhere in the Data Studio window.

Displaying Cursor Information for Variables During Debugging

In Data Studio, variable information is displayed if the cursor is hovered over that variable during debugging of PL/SQL function.

Supporting Rollback/Commit During Debugging

Data Studio provides the option to commit/rollback the PL/SQL query execution result after debugging is finished.

  • If Debug With Rollback option is enabled, then the PL/SQL execution result after debugging is not saved in the database.
  • If Debug With Rollback option is disabled, then the PL/SQL execution result after debugging is committed in the database.

Follow the steps to enable the rollback feature the feature:

  1. Check the Debug With Rollback box to enable the rollback feature during PL/SQL debugging

    Or

    Right click on SQL Terminal window where is PL/SQL function is executed.

    Select Debug With Rollback to enable rollback feature after the debugging is finished.

    Or

    Right click on any PL/SQL function under Functions/Procedure in Object Browser.