Tuesday 10 May 2016

Display details of Highest 10 salary paid employee

DECLARE
          CURSOR c1 IS SELECT  * FROM emp ORDER BY sal DESC;
          e_rec  emp%rowtype;
BEGIN
          FOR e_rec IN c1
          LOOP
DBMS_OUTPUT.PUT_LINE('Number: ' || ' ' || e_rec.empno);
DBMS_OUTPUT.PUT_LINE('Name  : ' || ' ' || e_rec.ename);
DBMS_OUTPUT.PUT_LINE('Salary: ' || ' ' || e_rec.sal);
          EXIT WHEN c1%ROWCOUNT >= 10;
          END LOOP;
END;

No comments:

Post a Comment