Composite Foreign key [message #18907] |
Wed, 20 February 2002 19:14 |
Tariq Zia lakho
Messages: 8 Registered: February 2002
|
Junior Member |
|
|
Hye.
I want to create a foeign compsite key, where i have been creeated Composite primary key on three columns.
column name are as under
1.inv_no
2.reg_no
2.season
when i make composite key with this command an error generated by oracle.
plz give me advice or session
i will be very thankful to u.
ALTER TABLE INV_DTL
ADD CONSTRAINTS INV_NO_REF_NO_SEASON_FK FOREIGN KEY INV_NO,REF_NO,SEASON)
REFERENCES INV_MST
Error return from oracle.
ERROR at line 2:
ORA-02298: cannot validate (UREA.INV_NO_REF_NO_SEASON_FK) - parent keys not found
|
|
|
Re: Composite Foreign key [message #18909 is a reply to message #18907] |
Wed, 20 February 2002 19:32 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
There are row(s) in your detail table which do not have a corresponding row in the master (header) table based on those three columns.
You will need to identify and delete/correct those rows. Here is how to identify them:
select *
from inv_dtl d
where not exists
(select null
from inv_mst m
where m.inv_no = d.inv_no
and m.ref_no = d.ref_no
and m.season = d.season);
|
|
|
|
Re: Composite Foreign key [message #21401 is a reply to message #18907] |
Thu, 01 August 2002 07:13 |
Bruno
Messages: 12 Registered: May 2002
|
Junior Member |
|
|
got similar problem. Using the select statement I could identify 33 records. But when changing SELECT into DELETE results in ORA-00903: invalid table name !!
How is this possible ??
Thanks.
|
|
|