PL/SQL Package example

Published on by LakshmiSaahul,Dhana Royal

CREATE OR REPLACE PACKAGE test AS -- package spec
TYPE list IS VARRAY(25) of NUMBER(3);


PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2);
PROCEDURE fire_employee (emp_id INTEGER);
PROCEDURE raise_salary (emp_id INTEGER, amount REAL);
END test;
/


Then we created the package body.


CREATE OR REPLACE PACKAGE BODY test AS -- package body
PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2) IS
BEGIN
INSERT INTO employee VALUES (emp_id, name, 1000);
END hire_employee;


PROCEDURE fire_employee (emp_id INTEGER) IS
BEGIN
DELETE FROM employee WHERE empno = emp_id;
END fire_employee;


PROCEDURE raise_salary (emp_id INTEGER, amount REAL) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Increase Salary :' || to_char(amou
nt));
UPDATE employee SET sal = sal + amount WHERE empno = emp_id;
END raise_salary;
END test;

Advertising
To be informed of the latest articles, subscribe:
Comment on this post