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