Sunday, 14 October 2012

ORA-02437: cannot validate - primary key violated

SQL>ALTER TABLE ONLS.ONLS_BIL_FINTX ADD CONSTRAINT ONLS_BIL_FINTX_PK
 PRIMARY KEY  (TRANS_REF_NO, TRANS_SEQ_NO) ENABLE NOVALIDATE;

ORA-02437: cannot validate (ONLS.ONLS_BIL_FINTX_PK) - primary key violated



Solution
=============
------- First, create a NON-UNIQUE index on the same fields that you want to
--------include in the constraint.
alter table ONLS_BIL_FINTX drop constraint ONLS_BIL_FINTX_PK;

create index IND_ONLS_BIL_FINTX on ONLS_BIL_FINTX(TRANS_REF_NO, TRANS_SEQ_NO);

-------- Then add the unique or primary key constraint.

 ALTER TABLE ONLS.ONLS_BIL_FINTX ADD CONSTRAINT ONLS_BIL_FINTX_PK
 PRIMARY KEY  (TRANS_REF_NO, TRANS_SEQ_NO) ENABLE NOVALIDATE;

No comments:

Post a Comment

Number of Visitors