Write PL/SQL code that use the cursor the highest paid employee from emp table?

declare
                highest number;
                name char(20);
                cursor c1 is
                                select ename,salary from emp;
                z c1%rowtype;
begin
                highest:=0;
                open c1;
                fetch c1 into z;
                for z in c1 loop
                                if salary>highest
                                                highest:=salary;
                                                name:=ename;
                                                fetch c1 into z;
                                end if;
                end loop;
                dbms_output.put_line('Name of Highest Paid Salary = '||name);
                dbms_output.put_line('Highest Salary = '||highest);
                close c1;
end;

 

Advertisements