How To Define an Anonymous Procedure with Variables

Q

How To Define an Anonymous Procedure with Variables? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and Functions

✍: FYIcenter.com

A

Anonymous procedure is a procedure without any name. If you have some variables to declare, you can define an anonymous procedure by using the DECLARE keyword in SQL*Plus as shown in the following tutorial script:

SQL> set serveroutput on;

SQL> declare
  2    site char(80) := 'FYICenter';
  3  begin 
  4    dbms_output.put_line('Welcome to ' || site); 
  5  end;
  6  /
Welcome to FYICenter

PL/SQL procedure successfully completed.

SQL>  /
Welcome to FYICenter

PL/SQL procedure successfully completed.

"/" runs the anonymous block, which print the "Welcome to FYICenter" message.

2007-04-26, 4317👍, 0💬