Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rudimentary issue: basic PL/SQL console output? [duplicate]

People also ask

How do you display output in PL SQL?

In the DBMS Output window, choose the "plus" icon and select the connection that you want to write data to the DBMS Output window. Then run the PL/SQL block in the SQL Worksheet window using the right arrow (Ctrl+Enter in Windows). You'll see the output appear in the DBMS Output window.

How do I run an anonymous block in PL SQL Developer?

First, connect to the Oracle Database server using Oracle SQL Developer. Second, create a new SQL file named anonymous-block. sql resided in the C:\plsql directory that will store the PL/SQL code. Third, enter the PL/SQL code and execute it by clicking the Execute button or pressing the Ctrl-Enter keyboard shortcut.

What is set Serveroutput on in PL SQL?

To redirect messages in the DBMS_OUTPUT message buffer to standard output, specify SET SERVEROUTPUT ON. In this example, the PUT procedure adds partial lines to the DBMS_OUTPUT message buffer. When proc1 runs, because SET SERVEROUTPUT ON is specified, the text stored in the DBMS_OUTPUT message buffer is displayed.


Since you are using SQL Developer, you have a couple of options.

In SQL Developer, go to View | DBMS Output to ensure that the DBMS Output window is visible. In the DBMS Output window, choose the "plus" icon and select the connection that you want to write data to the DBMS Output window. Then run the PL/SQL block in the SQL Worksheet window using the right arrow (Ctrl+Enter in Windows). You'll see the output appear in the DBMS Output window.

Alternately, you can put both the SQL*Plus SET SERVEROUTPUT ON command and the PL/SQL block in the SQL Worksheet and run it as a script (F5 in Windows). That will display the output immediately below the "anonymous block completed" message in the Script Output window.

Note: Dbms Output in Oracle Sql Developer doesn't show null in the output window. It moves to a new line, but until it will return something else than null, you'll not know all the previous nulls are there.