problem with sql
633183Apr 11 2008 — edited Apr 11 2008Hi Freinds,
here is simple SQL.I am not getin any o/p.
could you please help me findin the problem
Thanks,
Raj.
declare
vename emp.ename%type;
vdeptno emp.deptno%type;
vsal emp.sal%type;
vdname dept.dname%type;
vdeptno1 dept.deptno%type;
vgrade salgrade.grade%type;
vlosal salgrade.losal%type;
vhisal salgrade.hisal%type;
cursor c1 is select ename,deptno from emp;
cursor c2 is select dname,deptno from dept;
cursor c3 is select losal,hisal,grade from salgrade;
begin
open c1;
loop
fetch c1 into vename,vdeptno;
exit when c1 %notfound;
open c2;
loop
fetch c2 into vdname,vdeptno1 ;
exit when c2 %notfound;
open c3;
loop
fetch c3 into vlosal,vhisal,vgrade ;
exit when c3 %notfound;
if vdeptno=vdeptno1 and vsal between vlosal and vhisal then
dbms_output.put_line(vename||' works for the dept ' ||vdname||' has a salgrade '||vgrade);
end if;
end loop;
close c3;
end loop;
close c2;
end loop c1;
close c1;
end;