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!

Parent key not found error

SmileJul 27 2011 — edited Jul 27 2011
Hi
I've created the following 2 tables
create table cruise_orders
(cruise_order_id number,
order_date date,
constraint pk_co primary key (cruise_order_id, order_date));

create table order_returns (
order_return_id number,
cruise_order_id number,
cruise_order_date date,
constraint pk_or primary key (order_return_id),
constraint fk_or_co foreign key
( cruise_order_id,cruise_order_date )
 references cruise_orders (cruise_order_id , order_date))
And i inserted 2 records into cruise_orders table
insert into cruise_orders values(1,sysdate) 
insert into cruise_orders values(2,sysdate) 
SQL> select *from cruise_orders;

CRUISE_ORDER_ID ORDER_DAT
--------------- ---------
              1 27-JUL-11
              2 27-JUL-11
And i tried to insert the records into order_returns table
But getting the parent key not found error.. though the record exists in the parent table
SQL> insert into order_returns values(1,1,sysdate);
insert into order_returns values(1,1,sysdate)
*
ERROR at line 1:
ORA-02291: integrity constraint (SCOTT.FK_OR_CO) violated - parent key not
found
Guide me where i'm doing mistake.

Thanks
This post has been answered by Riaz on Jul 27 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2011
Added on Jul 27 2011
1 comment
543 views