create trigger a_tri
before insert on a 
for each row
begin
insert into b values(:new.col,....);
if :old.col=条件 then
:new.flag:='0';
end if;
end;
/

解决方案 »

  1.   

    To beckhambobo(beckham) :
       我在主表和从表之间建立了主外键关联啊,你的Insert语句会报错的.
      

  2.   

    用 after insert好了。after触发器是在记录生成后触发的。
      

  3.   

    To iwantsay(吵闹):
       after Insert触发器里不能对主表的标记位(iFlag)进行修改啊。我也是做的after Insert触发器,它不支持对:new里的成员进行修改。我又试过在这里用update语句更新,可是它也不支持对:new里的成员的访问,你看是不是?
    在after insert触发器里写了以下的语句:
    update 主表 set iflag=新标记 where 主键=:new.主键值;
    上面这条语句会报错的!
      

  4.   

    那你可以做把两件事情分在两个触发器里做啊。更新iFlag用 before insert。新增从表记录用 after insert。
      

  5.   

    FOREIGN KEY constraints for the rules associated with referential integrity. Oracle supports the use of FOREIGN KEY integrity constraints to define the referential integrity actions, including: 
    Update and delete No Action 
    Delete CASCADE 
    Delete SET NULL 详情参考:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/c18trigs.htm#12312
      

  6.   

    iwantsay(吵闹):
       你说的方法我想过,可是我要在插入从表之后根据插入的情况来设置iFlag标记位啊。beckhambobo(beckham):
       你能说详细点吗?谢谢两位了!