I have been working on this homework problem for two days now and at the conclusion that I cannot figure it out. Before I pull all of my hair out, could someone give me a hand? I would appreciate it very much!!
Question #1:
Create PL/SQL function (EMP_SAL_DIFF) that accepts an employee number (P_EMPLOYEE_ID) and returns the difference between the average salary in the department the employee works for and the employee’s salary.
In addition, create a driver program that runs the function against every employee in the EMPLOYEES table. Show all work including the output from running the procedure.
__________________________
Here is the work I have done so far. It isn't much. Its just the part where the employee salary is obtained from his/her department. I have no clue as to what to do with the rest. Thanks very much in advance!!
Create or replace function get_Sal ( P_EID IN NUMBER) RETURN NUMBER
IS
V_SAL EMPLOYEES.SALARY%TYPE;
BEGIN
SELECT SALARY
INTO V_SAL
FROM EMPLOYEES
WHERE EMPLOYEE_ID = P_EID;
RETURN V_SAL;
END;
/
variable g_sal NUMBER
EXECUTE :g_sal := get_Sal (199)
Print g_sal
Thanks, Cyndi