Package Specification: Pankaj Jain @twit - Pankajj
Package Specification: Pankaj Jain @twit - Pankajj
Package Specification: Pankaj Jain @twit - Pankajj
Pankaj Jain
@twit_pankajj
!!
Logical Grouping
Global Variables
Session Data
Selective
Exposure
Better
Application
Design
Performance
Package
Structure
Package Specification
Public APIs, Variables & Objects
No Implementations
Can Exist Independently
Package Body
Implementations
Private APIs, Variables & Objects
Cannot Exist Independently
Do Not Place Anything in
This Space
(Add watermark during editing)
Note: Warning will not appear
during Slide Show view.
Contents of Package
Procedures
Functions
Cursors
Records &
Collections
Others
Package Specification
CREATE PROCEDURE
CREATE ANY PROCEDURE
Package Specification
!
CREATE OR REPLACE PACKAGE hr_mgmt AS
!
g_active_status CONSTANT VARCHAR2(1) := 'A';
g_inactive_status CONSTANT VARCHAR2(1) := 'I';
!
g_bonus_pct NUMBER;
!
dept_not_found_ex EXCEPTION;
!
TYPE g_rec IS RECORD(p_profit NUMBER, p_dept_name departments.dept_name%TYPE);
!
!
!
END hr_mgmt;
Do Not Place Anything in
This Space
(Add watermark during editing)
Note: Warning will not appear
during Slide Show view.
Order of Declaration
Referenced Items Declared Before Referring Items
!
CREATE OR REPLACE PACKAGE hr_mgmt AS
!
!
dept_not_found_ex EXCEPTION;
!
TYPE g_rec IS RECORD(p_profit NUMBER, p_dept_name departments.dept_name%TYPE);
!
!
!
END hr_mgmt;
/
!
CREATE OR REPLACE PACKAGE hr_mgmt AS
!
g_active_status CONSTANT VARCHAR2(1) := 'A';
g_inactive_status CONSTANT VARCHAR2(1) := 'I';
g_bonus_pct NUMBER;
.
.
..
END hr_mgmt;
/
@C:\Demo\hr_mgmt.spc
DECLARE
l_emp_id
NUMBER(10) := 50;
l_dept_name VARCHAR2(60):= 'IT';
BEGIN
demo.hr_mgmt.update_emp(l_emp_id,l_dept_name);
END;
DECLARE
l_profit
NUMBER(10) := 100000;
l_dept_id NUMBER
:= 1;
l_bonus
NUMBER;
BEGIN
l_bonus:= demo.hr_mgmt.calc_bonus(l_profit, l_dept_id);
END;
!
BEGIN
DBMS_OUTPUT.PUT_LINE(demo.hr_mgmt. g_bonus_pct);
END;
DECLARE
l_dept_id NUMBER;
BEGIN
OPEN hr_mgmt.gcur_get_deptid(l_dept_name);
FETCH hr_mgmt.gcur_get_deptid INTO l_dept_id;
CLOSE hr_mgmt.gcur_get_deptid;
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(demo.hr_mgmt. g_active_status);
END;
!
CREATE OR REPLACE PACKAGE hr_mgmt AS
g_active_status CONSTANT VARCHAR2(1) := 'A';
g_bonus_pct NUMBER;
..
..
END hr_mgmt;
/
BEGIN
hr_mgmt. g_bonus_pct := 10;
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(demo.hr_mgmt. g_bonus_pct);
END;
Do Not Place Anything in
This Space
(Add watermark during editing)
Note: Warning will not appear
during Slide Show view.
Summary
Package Specification
Contents
Order of Declaration