分析原因:
在oracle中,主健不能自动生成,不过可以通过“序列”来实现,如果是这样的话,问题很可能就出在“序列”上了;
ORACLE表主键ID突然从已经存在的ID值开始自动生成,导致违反主键唯一性约束;
先上个触发器:
TRIGGER LESEIL."RIGHT"
BEFORE INSERT ON LESEIL."RIGHT" FOR EACH ROW
DECLARE last_Sequence NUMBER;
last_InsertID NUMBER;
BEGIN
IF (:NEW."RIGHTID" IS NULL) THEN
SELECT "Seq_RIGHTID".NEXTVAL INTO :NEW."RIGHTID" FROM DUAL;
ELSE
SELECT Last_Number- INTO last_Sequence FROM User_Sequences WHERE UPPER(Sequence_Name) = UPPER('Seq_RIGHTID');
SELECT :NEW."RIGHTID" INTO last_InsertID FROM DUAL;
WHILE (last_InsertID > last_Sequence) LOOP
SELECT "Seq_RIGHTID".NEXTVAL INTO last_Sequence FROM DUAL;
END LOOP;
END IF;
END;
解决办法:
待解决!