Executing Blocks

Contact Us or call 1-877-932-8228
Executing Blocks

Executing Blocks

PL/SQL Blocks can be executed from within SQL*Plus or SQLDeveloper. The following block includes two styles of comments available in PL/SQL. Comments contain text that is ignored by the compiler. One style of comments is useful for comments that span multiple lines and includes a closing character sequence. The other applies to single line comments and does not require any closing character sequence. The executable statement references a stored procedure called PUT_LINE in the DBMS_OUTPUT package supplied with Oracle. The intended result of executing the block is to display the character string passed as a parameter to the procedure on the screen.

Code Sample:


 A slash followed by an asterisk indicates a multiline comment
 that continues until an asterisk followed by a slash is encountered.

--Lines that begin with two dashes are comments and will be ignored.

  dbms_output.put_line('Hello World - from inside a PL/SQL block.');

Code Explanation

You should see "Hello World - from inside a PL/SQL block." displayed. As indicated in the last chapter, in SQL*Plus you must run a SET SERVEROUTPUT ON command in order to see results of this program (and any other program that utilizes the DBMS_OUTPUT package for output). SQLDeveloper includes a button to toggle SERVEROUTPUT on or off. You can click this button on the DBMS output tab instead of running the command.