Writing Your First Program

PL/SQL programs can be written and executed from the SQL prompt in SQL*Plus. Due to the complexity of the programs, this is not the preferable mechanism. It is best to develop the program in an external text editor such as Notepad or in Oracle’s Procedure Builder. The program files can then be called from SQL*Plus and be executed.

Our first program will output the message Hello. This program is contained in Listing 14.1.

Listing 14.1. A Simple PL/SQL Code Block That Displays the Word Hello
SQL> set serveroutput on 
SQL> begin 
  2   dbms_output.put_line ('Hello'); 
  3  end; 
  4  / 
Hello 

PL/SQL procedure successfully completed. 

SQL> 

End listing 

This program consists of a PL/SQL code block that contains a command. The DBMS_OUTPUT.PUT_LINE ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.