Posted By

wh0emPah on 04/01/10


Tagged


Versions (?)

jljl


 / Published in: PL/SQL
 

  1. CREATE OR REPLACE PROCEDURE P3_5_BEST_BETAALDE_PER_DEPT AS
  2. CURSOR C_DEPTS IS
  3. SELECT ID, NAME
  4. FROM S_DEPT
  5. ORDER BY ID ASC;
  6.  
  7. CURSOR C_EMPLOYEE (P_DEPTID IN NUMBER) IS
  8. SELECT LAST_NAME, FIRST_NAME, MAX(SALARY) SALARY
  9. FROM S_EMP
  10. WHERE DEPT_ID = P_DEPTID
  11. GROUP BY LAST_NAME, FIRST_NAME;
  12.  
  13. R_EMP C_EMPLOYEE%ROWTYPE;
  14. FOR R_DEPT IN C_DEPTS LOOP
  15. OPEN C_EMPLOYEE(R_DEPT.ID);
  16. FETCH C_EMPLOYEE INTO R_EMP;
  17. DBMS_OUTPUT.PUT_LINE(R_DEPT.ID ||' ' || R_DEPT.NAME || ' ' || R_EMP.LAST_NAME || ' ' ||R_EMP.FIRST_NAME || ' ' || R_EMP.SALARY);
  18. CLOSE C_EMPLOYEE;
  19. END P3_5_BEST_BETAALDE_PER_DEPT;

Report this snippet  

You need to login to post a comment.