在oracle数据表里插入数据,报错ORA-02287: 此处不允许序号
语句如下
INSERT INTO DI.HDPT_JOB(JOB_ID,JOB_NAME,ParentFolderName,TarGzName,CREATE_TIME,STATE)
select AUTO_ICRMT_ID_SEQ.NEXTVAL,'','20220927','user',SYSDATE,1 from dual
union all
select AUTO_ICRMT_ID_SEQ.NEXTVAL,'','20220927','device',SYSDATE,1 from dual
原因:oracle不让这样使用序列,具体说明如下:
Restrictions on Sequence Values You cannot use CURRVAL and NEXTVAL in the
正确方式:
INSERT INTO DI.HDPT_JOB(JOB_ID,JOB_NAME,ParentFolderName,TarGzName,CREATE_TIME,STATE)
select AUTO_ICRMT_ID_SEQ.NEXTVAL,t.c1,t.c2,t.c3,t.c4,t.c5 from
(
select '' c1,'20220927' c2,'user' c3,SYSDATE c4,1 c5 from dual
union all
select '','20220927','device',SYSDATE,1 from dual
)t