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!

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

user11301181Mar 9 2014 — edited Mar 9 2014

Now I've other problem with this error: ORA-02291: integrity constraint (%s.%s) violated - parent key not found"

the tables are following:

table1 (country, hobby,name) with primary key country+hobby and unique key name not nulls,

CREATE TABLE table1

(     country VARCHAR;

     hobby VARCHAR;

     name1 VARCHAR,

CONSTRAINT PK_T1 primary key country,hobby

CONSTRAINT UK_T1 unique name;

)

table2 (ID, name, birthdate) primary key ID not nulls

CREATE TABLE table2

(      ID VARCHAR,

       name VARCHAR,

     birthdate varchar

CONSTRAINT PK_T2 ID);

table3 (ID,hobby,country) primary key is ID+hobby and Foreign key FK1 is country + hobby references to table 1; and foreign key FK2 is ID references table2  not nulls;

CREATE TABLE table3

(     ID VARCHAR,

     hobby VARCHAR,

     country VARCHAR,

CONSTRAINT PK_T3 primary key ID,hobby,

CONSTRAINT FK1_T3 foreign key ID references table2(ID)

CONSTRAINT FK2_T3    foreign key (country,hobby) references table1 (country,hobby)

);

table4 ID,name, birthdate, country,hobby,name1) not null and duplicates

I'm trying to insert into table3 the info from table 4 preserving the references to table 1 and table 2 with the instruction:

     INSERT INTO tabla3 (ID,hobby,country) FROM table4 group by ID,hobby,country;

The propmt shows the ORA-02291 error because not references into table2.

Example:

table4

1     Ann      30-01-1988      England      football    England Football

1     Ann      30-01-1988      England       basket     England Basket

2     Alex     15-02-1985     Russia          hockey     null


table1

     England     football     England Football

     England     basket     England Basket


table2

     1     Ann     30-01-1998    

     2     Alex     15-02-1985


table 3 (must contain following)

     1     england      football

     2      england      basket

Thanks on advance.

kind regards

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2014
Added on Mar 9 2014
1 comment
1,710 views