oracle 编程 :在Scott下 创建员工表的触发器,删除,修改时候在屏幕输出更新后的表信息,4列分别为 ,部

2025-03-23 06:25:41
推荐回答(1个)
回答1:

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;