suresh1977,
No comment has been added lately (288 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
RECOMMENDATION: Award points to viswapsp http:#7518102
Please leave any comments here within 7 days.
-- Please DO NOT accept this comment as an answer ! --
Thanks,
graham_charles
EE Cleanup Volunteer
Main Topics
Browse All Topics





by: viswapspPosted on 2002-12-01 at 16:11:44ID: 7518102
Hi Suresh,
y('MANAGER ') FROM DUAL; y('MANAGER ');
One of the advantage of having packages is to have overloading which is not possible from standalone stored procedures. I have given one example here for your reference, which I hope will help you. I use the standard table EMP which has EMPNO, ENAME, JOB, MGR, DEPTNO as the columns.
1. Compile the below mentioned code package first and then package body.
2. Usage: you can use from SQL> prompt as
a. SELECT pkg_employee.gettotalsalar
b. You can use in PL/SQL Programming by assigning to a different variable.
x := pkg_employee.gettotalsalar
CREATE OR REPLACE PACKAGE pkg_Employee AS
FUNCTION getTotalSalary(i_Deptno IN NUMBER)
RETURN NUMBER;
FUNCTION getTotalSalary(i_JobCode IN VARCHAR2)
RETURN NUMBER;
END;
/
CREATE OR REPLACE PACKAGE BODY pkg_Employee AS
FUNCTION getTotalSalary(i_Deptno IN NUMBER)
RETURN NUMBER IS
l_TotalSalary NUMBER;
BEGIN
SELECT NVL(SUM(SAL), 0)
INTO l_TotalSalary
FROM EMP
WHERE DEPTNO = i_Deptno;
RETURN (l_TotalSalary);
END;
FUNCTION getTotalSalary(i_JobCode IN VARCHAR2)
RETURN NUMBER IS
l_TotalSalary NUMBER;
BEGIN
SELECT NVL(SUM(SAL), 0)
INTO l_TotalSalary
FROM EMP
WHERE JOB = i_JobCode;
RETURN (l_TotalSalary);
END;
END;
/
Any questions let me know.
Thanks