From Oracle FAQ
Jump to: navigation, search

ORA-02291: integrity constraint (%s.%s) violated - parent key not found

What causes this error?[edit]

In a master-child relationship, the master record has to exist before the child can reference it. If not, an ORA-02291 error will be raised.

How to fix it[edit]

When you insert a child record, reference only those keys that are found in the master table.

E.g.: Let us say you have Department and Employee tables, and that Department is the master table and Employee references DEPTNO as a foreign key.

When you insert rows into Employee, make sure that the department number exists in the Department table. If not insert a row in Department table for the department number you are referencing.