首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

请问oracle触发器的有关问题。多谢 。

2012-04-11 
请教oracle触发器的问题。谢谢 。。对触发器不熟悉,求教各位两个触发器。。有两个表:A---------A1A2B--------B1

请教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;

热点排行