create or replace trigger T_emp
after delete or update
on emp
declare
v_deptno int;
v_count int;
v_sal number(10,2);
v_sr number(10,2);
cursor c_emp is
select deptno,count(*),sum(sal),sum(nvl(comm,0)+nvl(sal,0)) from emp group by deptno;
begin
open c_emp;
loop
fetch c_emp into v_deptno,v_count,v_sal,v_sr;
exit when c_emp%notfound;
dbms_output.put_line(v_deptno||','||v_count||','||v_sal||','||v_sr);
end loop;
end;