declare
rec emp%rowtype;
c1 number :=0;
c2 number :=0;
c3 number :=0;
c4 number :=0;
cursor a1 is select * from emp;
begin
open a1;
loop
fetch a1 into rec;
exit when a1%notfound;
if rec.deptno = 10 then
c1 := c1 +1;
elsif rec.deptno = 20 then
c2 := c2 +1;
elsif rec.deptno = 30 then
c3 := c3 +1;
else
c4 := c3+1;
end if;
end loop;
close a1;
dbms_output.put_line('count of deptno 10 = '|| c1||' count of deptno 20 = ' ||c2|| ' count of deptno 30 = ' ||c3||' count of deptno 40 = ' || c4);
end;
/
Tuesday, March 24, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment