If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Need help on Function problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-19-03, 15:05
syndee1 syndee1 is offline
Registered User
 
Join Date: Oct 2003
Posts: 6
Unhappy Need help on Function problem

Hello everybody:

I have been working on this function problem for over two days (homework assignment). I cannot figure out how to do it and am not finding any help in doing this. Here is the problem:

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 that I have done so far, but its only the part about obtaining the salary for a certain employee.

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

Help would be greatly appreciated!! I think I've pulled out all my hair while trying to do this.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On