PLSQL Lecture-6
PLSQL Lecture-6
CREATING PACKAGES
PLSQL Tip
Error: Output buffer overflow
Solution: set the buffer size to a larger value
How
PACKAGES
1- Package Specification
2- Package Body
CREATE A PACKAGE
A package is to be created that will contain a function
and a procedure.
Creating Package
Specification
PROCEDURE to
calculate NET_SAL
This Procedure will take empno as an input
and it will show NET PAY [sal + comm]
comm] of that employee.
FUNCTION FIND_EMP
Function namely FIND_EMP will confirm
that the record of a particular employee exists or not
before executing NET PAY procedure.
FUNCTION FIND_EMP
create or replace Function find_emp (v_empno in number)
return boolean
is
v_temp number;
begin
select empno into v_temp from emp
where empno = v_empno;
Oracle includes about 20
predefined exceptions (errors) return(TRUE);
we can allow Oracle to raise
exception
these implicitly.
when no_data_found then
when too_many_rows then
return(FALSE);
when no_data_found then
when others then
END;
See more details on web/Book
CALLING FIND_EMP
FUNCTION
FROM NET_SAL
PROCEDURE
DBMS_OUTPUT. PUT_LINE
('Record not found of Employee ' || v_empno || '.');
end if;
END;
end emp_package;
emp_package;
Thanks
Q&A
Next PLSQL Triggers