I got this stored procedure in oracle
create or replace
procedure mayor_sueldo
as
cursor c_depto is select deptno from dept;
c_deptno dept.deptno%type;
c_empno number;
c_ename emp.ename%type;
c_job emp.job%type;
c_sal emp.sal%type;
begin
open c_depto;
fetch c_depto into c_deptno;
while ( c_depto%found )loop
select empno, ename, job, sal into c_empno, c_ename, c_job, c_sal from emp where sal = (select max(sal) from emp where(deptno = c_deptno) );
dbms_output.put_line( c_empno||'-'||c_ename||'-'||c_job||' '||c_sal );
fetch c_depto into c_deptno;
end loop;
close c_depto;
end;
the problem is inside the query inside the while block if the query returns one and only one row there is no problem but what about when the query return more than one row i was thinking that i could use another cursor but idk how.
please help me
maybe this will help:
for _row in (select ....) loop dbms_output(_row.a || ..); end loop;