编辑:我已经用实际的 SQL 替换了通用 SQL。
我知道如何解决它。我只是想知道为什么它适用于某些开发人员机器而不是其他机器。
CREATE TABLE OUTPUTDEFNACTIVATION ("OUTPUTDEFNACTIVATIONID" NUMBER, "OUTPUTDEFNTYPE" NUMBER(1,0) NOT NULL, "OUTPUTDEFNID" NUMBER NOT NULL, "PROJECTVIEWID" NUMBER, "SYSTEMUSERID" NUMBER, "VISIBLE" NUMBER(3,0));
ALTER TABLE OUTPUTDEFNACTIVATION ADD CONSTRAINT OUTPUTDEFNACTIVATION_P PRIMARY KEY (OUTPUTDEFNACTIVATIONID) ENABLE;
ALTER TABLE OUTPUTDEFNACTIVATION ADD CONSTRAINT OUTPUTDEFNACTIVATION_PROJECT FOREIGN KEY (PROJECTVIEWID) REFERENCES PROJECTVIEW (PROJECTVIEWID) ON DELETE CASCADE ENABLE;
ALTER TABLE OUTPUTDEFNACTIVATION ADD CONSTRAINT OUTPUTDEFNACTIVATION_USER FOREIGN KEY (SYSTEMUSERID) REFERENCES SYSTEMUSER (SYSTEMUSERID) ON DELETE CASCADE ENABLE;
ALTER TABLE OUTPUTDEFNACTIVATION ADD CONSTRAINT UNIQUE_OUTPUTDEFNACTIVATION UNIQUE (OUTPUTDEFNTYPE, OUTPUTDEFNID, SYSTEMUSERID, PROJECTVIEWID);
CREATE SEQUENCE "OUTPUTDEFNACTIVATION_SEQ" MINVALUE 1 MAXVALUE 1.00000000000000E+27 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;
INSERT INTO OUTPUTDEFNACTIVATION (OUTPUTDEFNTYPE, OUTPUTDEFNID, SYSTEMUSERID, PROJECTVIEWID, VISIBLE)
SELECT 0, KPIDEFNID, SYSTEMUSERID, PROJECTVIEWID, VISIBLE FROM KPIDEFN, SYSTEMUSER, PROJECTVIEW, DUAL WHERE ACTIVE = 1 AND SYSTEMUSERID <> 1 AND STATUSID IN (1,4);
我的解决方法是
INSERT INTO OUTPUTDEFNACTIVATION (OUTPUTDEFNACTIVATIONID, OUTPUTDEFNTYPE, OUTPUTDEFNID, SYSTEMUSERID, PROJECTVIEWID, VISIBLE)
SELECT OUTPUTDEFNACTIVATION_SEQ.NEXTVAL, 0, KPIDEFNID, SYSTEMUSERID, PROJECTVIEWID, VISIBLE FROM KPIDEFN, SYSTEMUSER, PROJECTVIEW, DUAL WHERE ACTIVE = 1 AND SYSTEMUSERID <> 1 AND STATUSID IN (1,4);
但是为什么在所有开发人员机器上都没有必要呢?他们都有自己的架构,但我的脚本为他们创建了这个表。
ORA-01400: cannot insert NULL into ("DEVF22FMT"."OUTPUTDEFNACTIVATION"."OUTPUTDEFNACTIVATIONID")