双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

幫忙看下,這個trigger什么問題

girl5201314 girl5201314 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
CREATE OR REPLACE TRIGGER SFCS.EF_STANDARD_WORK_T
AFTER INSERT OR UPDATE
ON SFCS.EF_STANDARD_WORK_HOURS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
WHEN (NEW.GROUP_ID IN (18,19,23,25,57))
DECLARE
tmpVar NUMBER;
models varchar(40);
Part_no varchar(20);
counts1 number;
counts2 number;
standard_work_time number;
CURSOR C_partno ;

/******************************************************************************
NAME: EF_STANDARD_WORK_T
PURPOSE:

REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 2008/8/29 1. Created this trigger.

NOTES:

Automatically available Auto Replace Keywords:
Object Name: EF_STANDARD_WORK_T
Sysdate: 2008/8/29
Date and Time: 2008/8/29, 上午 08:02:49, and 2008/8/29 上午 08:02:49
Username: (set in TOAD Options, Proc Templates)
Table Name: EF_STANDARD_WORK_HOURS (set in the "New PL/SQL Object" dialog)
Trigger Options: (set in the "New PL/SQL Object" dialog)
******************************************************************************/
BEGIN
if new.group_id in (18,19,23) then
select sum(standard_work_time) into standard_work_time
from ef_standard_work_hours
where model=:new.model
and group_id in (18,19,23);
select nvl(count(*),0) into counts2 from inv_pn where model=:new.model and SUBSTR (part_no, 1, 2)='70';
if counts2>0 then
CURSOR C_partno is select part_no from inv_pn where model=:new.model and SUBSTR (part_no, 1, 2)='70';
OPEN c_partno;

   LOOP
   FETCH c_partno INTO part_no;
   EXIT WHEN c_partno% NOTFOUND;
insert into ef_standard_work values (ERP_STANDARD_WORK_sequence.nextval,:new.model,part_no,standard_work_time,3,sysdate,sysdate,0);
end loop;
close c_partno;
end if;
else
begin
select sum(standard_work_time) into standard_work_time
from ef_standard_work_hours
where model=:new.model
and group_id in (25,27);

SELECT nvl(count(*),0) into counts1
FROM ef_standard_work
WHERE model = :new.model
AND SUBSTR (part_no, 1, 2)='95'
and a.model= :new.model;



select nvl(count(*),0) into counts2
from inv_pn
where model=:new.model
and SUBSTR (part_no, 1, 2)='95';

if counts2>0 then
declare
CURSOR C_partno is select part_no from inv_pn where model=:new.model and SUBSTR (part_no, 1, 2)='95';
begin
OPEN c_partno;

   LOOP
   FETCH c_partno INTO part_no;
   EXIT WHEN c_partno% NOTFOUND;
insert into ef_standard_work values
(ERP_STANDARD_WORK_sequence.nextval,:new.model,part_no,standard_work_time,3,sysdate,sysdate,0);
end loop;

close c_partno;
end;
end if;


end;
end if;

tmpVar := 0;
ELECT MySeq.NEXTVAL INTO tmpVar FROM dual;
:NEW.SequenceColumn := tmpVar;
:NEW.CreatedDate := SYSDATE;
:NEW.CreatedUser := USER;

EXCEPTION
WHEN OTHERS THEN
RAISE;
END EF_STANDARD_WORK_T;



...全文
评论 5
收藏 已收藏
分享
返回顶部
girl5201314
基础和管理 17,379 成员 95,111 内容