inserting error [message #78809] |
Mon, 18 March 2002 09:25  |
Angela
Messages: 13 Registered: October 2000
|
Junior Member |
|
|
I've already successful to insert data into table book and magazine (as below). But, why I cannot insert data into table reader? The error message is:
ORA-02291: integrity constraint (SCOTT.READER_2) violated - parent key not found
CREATE TABLE BOOK
(Book_Name VARCHAR(30) NOT NULL,
Edition_No VARCHAR(3) NOT NULL,
CONSTRAINT Book_PK PRIMARY KEY (Book_Name, Edition_No),
CONSTRAINT Book_U UNIQUE (Book_Name));
CREATE TABLE MAGAZINE
(Magazine_Name VARCHAR(30) NOT NULL,
Edition_No VARCHAR(3) NOT NULL,
Number_of_reporters NUMBER(4),
CONSTRAINT Magazine_PK PRIMARY KEY (Magazine_Name, Edition_No),
CONSTRAINT Magazine_U UNIQUE (Magazine_Name));
CREATE TABLE READER
(Reader_ID VARCHAR(10) NOT NULL,
Reader_name VARCHAR(30) NOT NULL,
Information_Name VARCHAR(20) NOT NULL,
Edition_No VARCHAR(4) NOT NULL,
CONSTRAINT Reader_PK PRIMARY KEY (Reader_ID),
CONSTRAINT Reader_U UNIQUE (Information_Name),
CONSTRAINT Reader_1 FOREIGN KEY (Information_Name) REFERENCES Book (Book_Name),
CONSTRAINT Reader_2 FOREIGN KEY (Information_Name) REFERENCES Magazine (Magazine_Name));
|
|
|
Re: inserting error [message #78818 is a reply to message #78809] |
Mon, 18 March 2002 23:56   |
pratap kumar tripathy
Messages: 660 Registered: January 2002
|
Senior Member |
|
|
in the reader table there is two foreign key on sam field "information_name", it seems little bit strange.
please review ur design.
according to current design , u can insert information_name if it exist in both book and makagize table.try inserting same book_name and magazine_name and the insert into reader table
ORA-02291 integrity constraint str.name violated - parent key not found
----------------------------------------------
Cause: An attempt was made to INSERT or UPDATE a foreign key value. The result was a value that is not in the parent key.
Action: UPDATE to or INSERT a value that is in the parent key.
|
|
|
Re: inserting error [message #78936 is a reply to message #78809] |
Thu, 04 April 2002 00:22  |
Ayan
Messages: 11 Registered: February 2002
|
Junior Member |
|
|
SCOTT>insert into book values('book1', '1')
SCOTT>/
1 row created.
SCOTT>insert into magazine values('book1', '1', 4)
SCOTT>/
1 row created.
SCOTT>insert into reader values ('1', '1', 'book1', '1')
SCOTT>/
1 row created.
SCOTT>commit;
Commit complete.
Everything is fine. Check the data that you are entering. Hope this will help you.
Ayan
|
|
|