DBMS_OUTPUT package generates the output to the screen in Oracle if used in PL/SQL programs. But to view the printed text, there is a need to run a specific command in Oracle. In Toad, there are three ways to enable output for DBMS_OUTPUT statements. Here are the examples:
Enable Output For DBMS_OUTPUT Statements in Toad For Oracle
Method – 1
- In Toad, click on the menu View > Toad Options to open the Options window.
- In the Options window, click on the Execute/Compile option under the Editor node.
- Then on the right side, click the option Poll for DBMS_OUTPUT to check the check-box and then click on the Apply and OK button to apply the setting permanently as shown in the below image. Now whenever you will run any PL/SQL program having the DBMS_OUTPUT statement, you will be able to view its output in DBMS Output window.
Method – 2
- In Toad, before running any PL/SQL program having the DBMS_OUTPUT statement, enable the output for DBMS Output window by clicking on the Red round icon, and it will turn to Green when it is on (below is a screenshot). This method is manual and every time you need to do when you restart the Toad.
Method – 3
- Put the SET SERVEROUTPUT ON statement before the PL/SQL program block to print the output of DBMS_OUTPUT statement on the Script Output Window in Toad and run the program by pressing the key F5. Below is an example:
SET SERVEROUTPUT ON BEGIN DBMS_OUTPUT.PUT_LINE('Hello World!'); END; /
Hello World! PL/SQL procedure successfully completed.