急问,触发器问题
我想建一个触发器,用的是Oracle9i,表A主要有姓名和部门编码字段,表B主要有部门编码和部门名称字段。我想当删除B表时A表对应部门行的部门编码字段变为空,想当修改B表时A表对应部门行的部门编码字段也随之修改!
谢谢了!
问题点数:100、回复次数:3Top
1 楼wl3721()回复于 2004-07-03 10:15:30 得分 34
CREATE TRIGGER B_trg
AFTER DELETE OR UPDATE OF B_BMBM ON TAB_B
FOR EACH ROW
declare
...
begin
...
if updating then
...
elsif deleting then
...
end if;
...
end;Top
2 楼superlcj(幽灵)回复于 2004-07-04 14:42:03 得分 33
CREATE TRIGGER B_trg
after DELETE OR UPDATE OF B_BMBM ON TAB_B
FOR EACH ROW
declare
...
begin
...
if updating then
...
update tab_a set 字段=:new.字段 where 字段=:old.字段;
elsif deleting then
...
update tab_a set 字段='' where 字段=:old.字段;
end if;
...
end;
Top
3 楼dinya2003(OK)回复于 2004-07-05 09:33:44 得分 33
create or replace trigger test
after update or delete on tableb
for each row
begin
if updatint then
update testa a set a.部门编码=:new.部门编码 where a.部门编码=:old.部门编码;
else
update testa a set a.部门编码='' where a.部门编码=:old.部门编码;
end if;
end;
Top




