请教oracle触发器的问题。谢谢 。。

ourwy 2012-01-04 08:12:33
对触发器不熟悉,求教各位两个触发器。。
有两个表:
A
---------
A1
A2

B
--------
B1
B2

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

请教各位。。 谢谢了。
...全文
97 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ourwy 2012-01-05
  • 打赏
  • 举报
回复
谢谢,ZZL,我按你说的写的,怎么会提示错误呢。表B发生了变化,触发器/函数不能读。 update b set b2='1' 这句话。
zzl880720zm 2012-01-05
  • 打赏
  • 举报
回复
迟到
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;
thousandlin 2012-01-05
  • 打赏
  • 举报
回复
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;
ourwy 2012-01-05
  • 打赏
  • 举报
回复
请教各位。。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧