如何插入nextval触发for循环内部 [英] How to insert nextval to trigger inside for loop
问题描述
这里是触发器的代码,它有一个for循环.触发触发器(INSERT或UPDATE)时,必须有另一个表数据包括MICL_SUP
Here is a code for trigger and it have a for loop. When trigger is fired (INSERT OR UPDATE) there's another table data must include it is MICL_SUP
OPEN projMgrsCursor;
LOOP
FETCH projMgrsCursor INTO projMgr;
select micl_sup_id_seq.nextval into SUPID from dual;
insert into MICL_SUP VALUES ((SUPID), (SELECT SYSDATE FROM DUAL), :NEW.ENTRYADDEDBY_EMP_NO, 3000, 0,projMgr, NULL,:NEW.EMP_NO);
END LOOP;
CLOSE projMgrsCursor;
这是表结构. Sup_ID
主键和唯一键.我无法对表结构进行任何更改
This is the table structure. Sup_ID
primary and unique key . I can't make any changes to table structure
SUP_ID -primary key
ASSIGNED_DATE
ASSIGNED_BY_EMP_NO
AMOUNT_LIMIT
IS_OVVERRIDDEN
SUP_EMP_NO
RTD_EMP
EMP_NO
要输入sup_ID,请使用select micl_sup_id_seq.nextval into SUPID from dual;
但是,当我运行此代码时,出现错误"RA-00001: unique constraint violated"
(这不是编译错误)还有其他方法可以添加sup_ID
吗?我在哪里弄错了?
To enter sup_ID I use select micl_sup_id_seq.nextval into SUPID from dual;
but when I run this code there's an error "RA-00001: unique constraint violated"
(this is not a compilation error ) Is there any other way to add sup_ID
? Where have I gone wrong?
此问题与此触发器 PlSQL触发器错误ORA-0000 ORA- 06512:
推荐答案
为什么不将micl_sup_id_seq.nextval
的计算包括到光标中?
Why not including calculation of micl_sup_id_seq.nextval
into your cursor?
cursor projMgrsCursor is
select b.BU_MEMBER_ID, micl_sup_id_seq.nextval SUPID
from ...
这篇关于如何插入nextval触发for循环内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!