0 Replies - 518 Views - Last Post: 10 May 2016 - 07:55 AM

#1 X.chan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-October 15

ORA-02291 : parent key not found !

Posted 10 May 2016 - 07:55 AM

hello friends,

I have a problem with a foreign key constraint, which is WAN_FK here.
I insert the data into a table (Author ) which has Aouthor_name as a primary key.
same in a (Book) table that has (ISBN) as a primary.

because these table have many to many relation , I created the "write" table which has :
- Primary key ( ISBN, AUTHOR_NAME)
- Foreign keys (ISBN) references the book table and (AUTHOR_NAME) references the author table.


I tried to solve that disable the foreign key constraint till I insert the data into "write table"

and this what happen.


SQL> ALTER TABLE WRITE
  2  ENABLE CONSTRAINT WAN_FK;
ENABLE CONSTRAINT WAN_FK
                  *
ERROR at line 2:
ORA-02298: cannot validate (SYSTEM.WAN_FK) - parent keys not found



I am so sure this is not because the data not matching...
please have a look to these select queries:

SQL> SELECT * FROM AUTHOR;

AUTHOR_NAME
--------------------------------------------------
P.J. DEITEL
H.M. DEILET
Dan Browen
Sameer Al-Ghamdi
Amal Sulaiman Ibrahim
Gazi Al-Qasabie
Salman Al-Oudah

7 rows selected.

SQL> SELECT * FROM WRITE;

      ISBN AUTHOR_NAME
---------- --------------------------------------------------
         1 P.J. DEITEL
         1 H.M. DEILET
         2 Dan Browen
         3 Sameer Al-Ghamdi
         4 Amal Sulaiman Ibrahim
         5 Gazi Al-Qasabie
         6 Salman Al-Oudah
         7 Amal Sulaiman Ibrahim
         8 Sameer Al-Ghamdi
         9 Sameer Al-Ghamdi
         9 Gazi Al-Qasabie

      ISBN AUTHOR_NAME
---------- --------------------------------------------------
        10 P.J. DEILET

12 rows selected.



can anyone help me ? :(

Is This A Good Question/Topic? 0
  • +

Page 1 of 1