Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> trigger - multiple columns
Here is data:
emp
enum ename deptno sal 1245 TOM 20 4000 3456 JOHN 10 3000
my_dept
deptno dname 20 Marketing 10 Sales
I need to update MY_DEPT after an employee in EMP is transferred to another
department or has a change in salary. How can I do this in one trigger?
How does one coordinate such conditional changes? I have this:
create or replace trigger trig_emp_update
after update of deptno
or update of sal
on emp
for each row
begin
update my_dept
set tot_sal = NVL(tot_sal,0) + :new.sal
where deptno = :new.deptno;
update my_dept
set tot_sal = NVL(tot_sal,0) - :old.sal
where deptno = :old.deptno;
end trig_emp_update;
Help
SHIRU‰
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Thu Nov 26 1998 - 14:08:34 CST