1、看不出来有什么问题,为什么不试试?
2、insert时,应该是不能操作当前行的

解决方案 »

  1.   

    我把2改为
    CREATE OR REPLACE TRIGGER GETPLANNO 
    AFTER INSERT ON ASALEPLANHEAD 
    begin
    Getcode ('PlacingPlanNo');
    update ASalePlanHead set PlanNO = 
    (select CurCode from tblcode where FieldName='PlacingPlanNo') 
    where id=(select max(id) from ASalePlanHead); --??? 这里有没有其它办法得到刚刚插入记录的 id 
    end;是可以的;
      

  2.   

    看看  update ASalePlanHead  不可以的 不能 对这个表操作
      

  3.   

    1.正确
    2.不对
    AFTER INSERT ON ASALEPLANHEAD 
    ....................
    update ASalePlanHead
    这样不行,在表ASALEPLANHEAD上建立触发器怎么还能在触发器
    里update ASalePlanHead???
    建议使用包和过程实现。
      

  4.   

    wwl007(疑难杂症) , lcz022(阿五)
    我这样子做,确实是可以的,我已经执行过了,
    我是想问问 有没有其它办法得到刚刚插入记录的 id 
    CREATE OR REPLACE TRIGGER GETPLANNO 
    AFTER INSERT ON ASALEPLANHEAD 
    begin
    Getcode ('PlacingPlanNo');
    update ASalePlanHead set PlanNO = 
    (select CurCode from tblcode where FieldName='PlacingPlanNo') 
    where id=(select max(id) from ASalePlanHead); --??? 这里有没有其它办法得到刚刚插入记录的 id 
    end;
      

  5.   

    1、应该没问题
    2、insert时,应该是不能操作当前行的,可能是oracle还未真正将此行写入,换其他方法
      

  6.   

    有一个问题 就是你不能在trigge 里面对这个表再update insert 操作 如果要得到也要在 trigge外边处理
      

  7.   

    CREATE OR REPLACE TRIGGER GETPLANNO 
    before INSERT ON ASALEPLANHEAD 
    FOR EACH ROW 
    begin 
    Getcode ('PlacingPlanNo');
    :new.PlanNO: = (select CurCode from tblcode where FieldName='PlacingPlanNo');
    end;
    /
    这样就可以了,行级别触发器,就是当前行的触发,不需用再判定