Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Foreign Key violation error during DELETE dure to Self referential FK

York35Aug 5 2009 — edited Aug 25 2009
DB Version:10gR2

In the below example, i have a self referencing foreign key mgr. When i DELETE records
i don't get an ORA-02292 error from the self referencing FK.
create table emp2 
 (
 empno number primary key,
 mgr   number references emp2( empno )
 );

Table created.



INSERT INTO EMP2 VALUES (2,2);

INSERT INTO EMP2 VALUES(3,NULL);

INSERT INTO EMP2 VALUES (4,3);

COMMIT;

SQL>DELETE FROM EMP2;

3 rows deleted.
But in one of our Production tables which has a self referential FK, i get an error similair to
ERROR at line 1:
ORA-02292: integrity constraint (SCOTT.EMP2_FK) violated - child record found
when i try to delete records.Any idea why i am getting this error?
This post has been answered by Peter Gjelstrup on Aug 5 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2009
Added on Aug 5 2009
11 comments
2,755 views