Oracle PL/SQL - PL SQL Function Procedure Package Stored procedures

Introduction

You can store PL/SQL code inside the database.

For example, you could store the first PL/SQL code as a standalone procedure.

Stored procedures use a slightly different syntax, shown here:

create or replace procedure p_hello 
is 
    my_val varchar2(256):='Hello, World!'; 
begin 
    dbms_output.put_line(my_val); 
end; 
/

Here, a PL/SQL program creates a stored procedure in the database.

When the procedure exists in the database, you can call the routine and get the result:

Demo

SQL>
SQL> create or replace procedure p_hello
  2  is-- w ww  . j  ava2  s  .  com
  3      my_val varchar2(256):='Hello, World!';
  4  begin
  5       dbms_output.put_line(my_val);
  6  end;
  7  /

Procedure created.

SQL>
SQL> begin
  2      p_hello;
  3  end;
  4  /
Hello, World!

PL/SQL procedure successfully completed.

SQL>

Related Topics