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

    You are trying to insert or update a record, but some of the values provided were not found in the parent table.



    eg:


    SQL> create table parent(id number primary key);

    Table created.

    SQL> create table child(id number, parent_id number references parent(id));

    Table created.

    SQL> insert into parent values(1);

    1 row created.

    SQL> insert into child values(1, 1);

    1 row created.

    SQL> insert into child values(1, 2);
    insert into child values(1, 2)
    *
    ERROR at line 1:
    ORA-02291: integrity constraint (AUSER.SYS_C005576) violated - parent key not
    found


    Value 2 does not exist in the parent table, so either insert it into that table, or provide a different value.



    Using the constraint name provided with the error message, you can lookup the columns affected:


    select child.owner||'.'||child.table_name||'.'||child.column_name||' must exist in '||
    parent.owner||'.'||parent.table_name||'.'||parent.column_name
    from
    all_cons_columns child
    , all_cons_columns parent
    , all_constraints c
    where c.owner='AUSER'
    and c.constraint_name='SYS_C005576'
    and child.owner=c.owner
    and child.constraint_name=c.constraint_name
    and parent.owner=c.r_owner
    and parent.constraint_name=c.r_constraint_name
    and child.position=parent.position
    /

    AUSER.CHILD.PARENT_ID must exist in AUSER.PARENT.ID



Adverteren bij Daisycon
Forum Messages
14-MAY-2008 10:39:49ORA-02298: cannot validate Anju Reply
The following error has occurred:

ORA-02298: cannot validate (MIS_INFO.PROMO_FK_SCCOGTYPE) - parent keys not found


my querry is:

ALTER TABLE PROMO_SENT_COMMUNICATION ADD CONSTRAINT PROMO_FK_SCCOGTYPE
FOREIGN KEY (SUB_TYPE)
REFERENCES MIS_INFO.PROMO_SUBTYPE (SUB_TYPE) ;
: ->  14-MAY-2008 11:53:43Values do no existsDbMotive Reply
You have values in your child table (PROMO_SENT_COMMUNICATION.SUB_TYPE) which do not exist in your parent table (MIS_INFO.PROMO_SUBTYPE.SUB_TYPE).

You can see what values do not exist and take corrective actions.

Add your message for ORA-02291
Name:email:
Validation Code:65oc7m0g52zvq8ovh
Enter Code above:
Title:
State your problem: