Re: Foreign Key constraint help!

From: OraSaurus <granaman_at_home.com>
Date: Thu, 24 Dec 1998 06:03:32 GMT
Message-ID: <UOkg2.234$xq4.213_at_news.rdc1.ne.home.com>


This error means that some record in the referencing table does not have a corresponding parent record in the referenced table. The foreign key violation prevents its creation. It is a data problem...

In article <367beb13.0_at_news1.mcmail.com>, "Dan Hield" <dan.hield_at_cwcom.net> wrote:
>Yes, I have created the primary keys on both tables sucessfully, hence 'not
>null' values in table description. This is why it puzzles me.
>
>Andrea Mattioli wrote in message <367BAA4C.965623FD_at_gedy.it>...
>>Have you defined the primary key on table1?
>>
>>Alter table table1 add primary key (col1,col2);
>>
>>Dan Hield wrote:
>>
>>> Using Oracle7, I am trying to create a foreign key on a table which has a
>>> composite key of three referencing another table which has a composite
>key
>>> of two.
>>>
>>> i.e.
>>> table1
>>> name Null? Type
>>> col1 not null varchar2(8)
>>> col2 not null varchar2(50)
>>> col3 varchar2(3)
>>> col4 number(3)
>>> col5 varchar2(2000)
>>>
>>> table2
>>> name Null? Type
>>> col1 not null varchar2(8)
>>> col2 not null varchar2(50)
>>> col3 not null varchar2(50)
>>>
>>> I get this error message: 'ORA-02294: cannot add referential constraint -
>>> paretn keys not found.'
>>>
>>> The script I am using to attemp to create the foreign key is as follows:
>>>
>>> ALTER TABLE2 ADD CONSTRAINT fk1
>>> FOREIGN KEY (col1, col2) REFERENCES TABLE1(col1, col2);
>>>
>>> Any help greatly appreciated. Keen to learn fast!
>>>
>>> Dan.
>>
>
>
Received on Thu Dec 24 1998 - 07:03:32 CET

Original text of this message