立即与支持人员聊天
与支持团队交流

Toad for Oracle 16.1 - Getting Started Guide

Welcome to Toad Toad Resources Required Privileges Create and Manage Database Connections Editor Basics Schema Browser Basics Data Grid Basics Work with Data Work with Database Objects Work with Code
Write Statements and Scripts Work with the Query Builder Execute Statements and Scripts Save Statements (SQL Recall) Work with PL/SQL Objects Debug Analyze Code Optimize SQL
Customize your Toad Environment Use Other Quest Software Products with Toad

Enable DBMS Output

Toad uses the Oracle-provided DBMS_OUTPUT package, which contains functions for debugging PL/SQL code. When enabled, it uses a buffer that your PL/SQL code writes into and then a separate process queries the buffer out and displays the contents.

When you are running debugging in the Editor and DBMS output is enabled, a DBMS Output tab automatically displays the results of DBMS_OUTPUT.PUT_LINE() statements in the Editor. You can also edit the DBMS Output content to make comments, delete specific lines of output, and so on. The standard copy, cut, and paste keys also work in the DBMS Output box.

To view DBMS Output in the Editor, you must enable DBMS Output before executing PL/SQL. The output displays after the procedure has completed execution, not while you are stepping through the code. In nested procedure calls, all procedures must have run to completion before any DBMS Output content is displayed.

Note: Output only displays after the procedure has completed execution, not while you are single stepping through the code. In the case of nested procedure calls, all procedures must have run to completion before any DBMS Output content is displayed.

To enable or disable DBMS output

At the top of the DBMS Output window, click the Enable/Disable toggle button.

To generate DBMS Output

Generate DBMS Output

To automatically insert DBMS_OUTPUT statements

You can use Toad's Auto Debugger feature to automatically insert DBMS_OUTPUT statements where applicable and remove them when done. See Automatically Insert DBMS_OUTPUT Statements (Auto Debugger) in the online help for more information.

Troubleshooting

If you do not see DBMS Output, try the following suggestions:

  • Right-click the lower pane and select Desktop | DBMS Output.
  • Make sure the Toggle Output On/Off button is on () in the DBMS Output tab.
  • Then, set the interval in the Polling Frequency box. If the toggle is on, Toad periodically scans for and displays DBMS Output content.
  • Contact your Oracle DBA to make sure the DBMS_OUTPUT package is enabled on your database.

 

View DBMS Output

DBMS_OUTPUT results only display after the procedure has completed execution, not while you are single stepping through the code. In nested procedure calls, all procedures must have run to completion before any DBMS Output content is displayed.

To open the DBMS Output window

On the main toolbar, select View | DBMS Output.

 

Edit DBMS Output

You can edit the output display in the DBMS Output window. This allows you to note what you did to receive the output.

For example, when debugging a procedure named MyProc that expects a single number parameter, you can execute the procedure from an Editor window with the following statement:

begin MYPROC(1); end;

Prior to executing the above, you can document the call in the DBMS Output with a comment:

Calling MyProc with 1

Then turn DBMS Output ON and execute MyProc. The DBMS_OUTPUT statements will display after your notes about the call.

 

Create and Run Unit Tests

After you execute or debug PL/SQL, results of the execution are available in the PL/SQL Results window. The window will be provided as a standalone window or as an Editor tab depending on where in Toad you initiated execution. When shown in the Editor, it's docked as a tab at the bottom of your screen, by default. From the PL/SQL Results window you can create complete unit tests using your execution input parameters and the output produced.

Toad supports creation of unit tests for the following frameworks:

  • Code Tester for Oracle
  • utPLSQL

You can also run Code Tester for Oracle tests from this window. Toad supports a subset of the Code Tester functionality for creating a new test, but Toad provides a direct link to Code Tester if you need more advanced functionality.

Prerequisites

Code Tester for Oracle

  • There must be a Code Tester repository on the database to which you are connected from Toad, and the Code Tester repository must be a version that is supported by the version of Toad that you are using. The repository version must be 3.0 or greater.
  • The feature is enabled only if there are results in the PL/SQL Results window.
  • To create a new test, all input and output values must be of a type supported by Code Tester.

Note: Code Tester does not have to be running to create or run tests in Toad.

utPLSQL

  • You must have a compatible version of utPLSQL framework installed. Only utPLSQL versions 3.1.4 through 3.1.9 are certified to work with Toad 16.1.
  • The connected schema must have access to the framework either through the use of public synonyms or appropriate grants on the framework's objects.

Creating Unit Tests

Code Tester for Oracle

To create a Code Tester unit test

  1. Click (Create Unit Test) to open the Create Test dialog.
  2. In the Create Test Case dialog, complete the test information. You can change values as needed.

    Note: By default, you are prompted to create a new test definition when you create the test case. Select Attach to Existing to attach the test case to an existing definition.

To run a Code Tester unit test

Click (Execute Code Tester for Oracle tests...).

To open Code Tester

Click on the PL/SQL Results toolbar or on the Code Tester Results dialog (after you run the test).

To add Code Tester unit tests to Team Coding

You can include your unit tests in your Team Coding projects. This enables you to manage the revision history of your tests in the same way that you manage the revisions of your other controlled objects. The user/schema who created the tests in Toad must be included in (or added to) the Team Coding project for the tests to be controlled. For more information, see Configure Team Projects.

utPLSQL

To create a utPLSQLunit test

  1. Click to open the Create Unit Test Window.
  2. The dialog has been populated with a new unit test using your inputs and the outputs produced. Set any additional properties and click Send to Editor to send the test suite DDL to the Editor for finalization.
  3. Review the code in the Editor, make changes as needed, and compile the test suite.

    Note: utPLSQL test suites are Oracle packages. You must compile the spec first and then the body as you would with any other new package.

 

相关文档

The document was helpful.

选择评级

I easily found the information I needed.

选择评级