SQL-What is Package

USA JobsA package according to Oracle PL/SQL – it is a combination of Procedures, Functions, Cursors,Exceptions. Putting all these objects in a procedural Language is called a package:

Source:Oracle document

Sample code how to create a package:

CREATE PACKAGE emp_bonus AS
PROCEDURE calc_bonus (date_hired employees.hire_date%TYPE);
END emp_bonus;
/
CREATE PACKAGE BODY emp_bonus AS
— the following parameter declaration raises an exception
— because ‘DATE’ does not match employees.hire_date%TYPE
— PROCEDURE calc_bonus (date_hired DATE) IS
— the following is correct because there is an exact match
PROCEDURE calc_bonus (date_hired employees.hire_date%TYPE) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(‘Employees hired on ‘ || date_hired || ‘ get bonus.’);
END;
END emp_bonus;
/

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.