Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> trigger - multiple columns

trigger - multiple columns

From: <shirushah_at_hotmail.com>
Date: Thu, 26 Nov 1998 20:08:34 GMT
Message-ID: <73kcfr$hda$1@nnrp1.dejanews.com>


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&#137; -----------== 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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US