日期:2014-05-17  浏览次数:20645 次

请教oracle触发器的问题。谢谢 。。
对触发器不熟悉,求教各位两个触发器。。
有两个表:
A
---------
A1
A2

B
--------
B1
B2

想写触发器。 
1 当更新 A表 的时候,如果 A1的值是 "1" , 就把A1,A2写入到B表中 B1,B2中。
2 当更新 B表的时候,如果 B1的值是"1",就把B2的值改为"1" .

请教各位。。 谢谢了。


------解决方案--------------------
1 当更新 A表 的时候,如果 A1的值是 "1" , 就把A1,A2写入到B表中 B1,B2中。
create or replace trigger Test_B_trigger

after insert or delete or update on Test_A
for each row

begin
  
 if updating then 
 
 if :new.A1 = '1' then 
 insert into Test_B
values( :new.A1,:new.A2) ;
 end if;
 
 --同理,如果需要在写入时候
 
/* if inserting then 
 
 end if;*/
 
end;

------解决方案--------------------
迟到
create or replace trigger B_trigger
after update on B
for each row
begin

if :new.b1='1' then
update b set b2='1';

end;