我把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;是可以的;
看看 update ASalePlanHead 不可以的 不能 对这个表操作
1.正确 2.不对 AFTER INSERT ON ASALEPLANHEAD .................... update ASalePlanHead 这样不行,在表ASALEPLANHEAD上建立触发器怎么还能在触发器 里update ASalePlanHead??? 建议使用包和过程实现。
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;
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; / 这样就可以了,行级别触发器,就是当前行的触发,不需用再判定
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.不对
AFTER INSERT ON ASALEPLANHEAD
....................
update ASalePlanHead
这样不行,在表ASALEPLANHEAD上建立触发器怎么还能在触发器
里update ASalePlanHead???
建议使用包和过程实现。
我这样子做,确实是可以的,我已经执行过了,
我是想问问 有没有其它办法得到刚刚插入记录的 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;
2、insert时,应该是不能操作当前行的,可能是oracle还未真正将此行写入,换其他方法
before INSERT ON ASALEPLANHEAD
FOR EACH ROW
begin
Getcode ('PlacingPlanNo');
:new.PlanNO: = (select CurCode from tblcode where FieldName='PlacingPlanNo');
end;
/
这样就可以了,行级别触发器,就是当前行的触发,不需用再判定