幫忙看下,這個trigger什么問題
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;
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;
...全文
相关推荐
PL/SQL Trigger PL/SQL TriggerPL/SQL TriggerPL/SQL Trigger
PL/SQL TriggerPL/SQL Trigger
WPF 绑定之Trigger
使用control自由的property作为trigger View Code ToggleButton Width="30" Height="30"> ToggleButton.Style> Style TargetType="ToggleButton"> Style.Triggers>
原生js实现trigger方法示例代码
主要给大家介绍了关于利用原生js实现trigger方法的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用js具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
SA_TRIGGER
SA_TRIGGER
jquery trigger函数执行两次的解决方法
主要介绍了jquery trigger函数执行两次的解决方法,详细分析了trigger函数执行两次的原因与响应的解决技巧,非常具有实用价值,需要的朋友可以参考下


基础和管理

