对触发器不熟悉,求教各位两个触发器。。
有两个表:
A
---------
A1
A2B
--------
B1
B2想写触发器。
1 当更新 A表 的时候,如果 A1的值是 "1" , 就把A1,A2写入到B表中 B1,B2中。
2 当更新 B表的时候,如果 B1的值是"1",就把B2的值改为"1" .请教各位。。 谢谢了。
有两个表:
A
---------
A1
A2B
--------
B1
B2想写触发器。
1 当更新 A表 的时候,如果 A1的值是 "1" , 就把A1,A2写入到B表中 B1,B2中。
2 当更新 B表的时候,如果 B1的值是"1",就把B2的值改为"1" .请教各位。。 谢谢了。
create or replace trigger Test_B_triggerafter insert or delete or update on Test_A
for each rowbegin
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;