This script demonstrates how to create and call a simple procedure. : Procedure Call « Stored Procedure Function « Oracle PL / SQL






This script demonstrates how to create and call a simple procedure.

   

SQL> CREATE TABLE emp (
  2    id         NUMBER PRIMARY KEY,
  3    fname VARCHAR2(50),
  4    lname  VARCHAR2(50)
  5  );

Table created.

SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE AddNewAuthor(p_ID emp.ID%TYPE,p_FirstName emp.fname%TYPE,p_LastName emp.lname%TYPE) AS
  2  BEGIN
  3    INSERT INTO emp (id, fname, lname) VALUES (p_ID, p_FirstName, p_LastName);
  4  END AddNewAuthor;
  5  /

Procedure created.

SQL>
SQL>
SQL> DECLARE
  2    
  3    v_NewFirstName emp.fname%TYPE := 'C';
  4    v_NewLastName emp.lname%TYPE := 'C';
  5    v_NewAuthorID emp.ID%TYPE := 100;
  6  BEGIN
  7    AddNewAuthor(v_NewAuthorID, v_NewFirstName, v_NewLastName);
  8  END;
  9  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> drop table emp;

Table dropped.

SQL>

   
    
    
  








Related examples in the same category

1.Call a stored procedure in a PL/SQL block
2.Call a stored procedure then other statements
3.Dependency Example
4.Forward Declarations
5.Exceptions in Subprograms
6.A PL/SQL procedure with no parameter
7.Exception throwed out of procedure call
8.Default parameter value
9.Pass parameter by data type
10.Calling ParameterLength illegally (ORA-6502)...
11.Use named notation
12.Use named notation, but with a different order of the formal parameters