当前位置: 代码迷 >> Oracle开发 >> 急这个触发器如何写
  详细解决方案

急这个触发器如何写

热度:86   发布时间:2016-04-24 08:02:05.0
急!!!!!!!~~~~~~~这个触发器怎么写!
create table a 
(
  a number(2),
  id number(2)
)
create table b
(
  b number(2),
  id number(2)
)
insert into a (a,id)values(1,9)
insert into b (b,id)values(2,9)


create trigger a_update
before update of a on a
referencing old as old_value
new as new_value
for each row
begin
:new_value.id:=5;
end

 
 drop trigger a_update;
 
update a set a=5

select *
from a

select*
from b

我想把a表中的a字段改为5,同时b表中的b字段也变成5

------解决方案--------------------
探讨
SQL code
create trigger a_update_trig
before update of a on a
for each row
begin
--:new.id:=5;
insert into a(a,id)values(5,:new.id);
commit;
update b set b=5 where id=:new.id;
commit;
end a……
  相关解决方案