Skip to Main Content

Oracle Database Discussions

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!

DEFERRABLE constraints - error

508936Nov 15 2007 — edited Nov 15 2007
Hi,

I am trying this example for DEFERRABLE constraints.


CREATE TABLE chicken(cID INT PRIMARY KEY,
eID INT);
CREATE TABLE egg(eID INT PRIMARY KEY,
cID INT);

Then, we add foreign key constraints:
ALTER TABLE chicken ADD CONSTRAINT chickenREFegg
FOREIGN KEY (eID) REFERENCES egg(eID)
INITIALLY DEFERRED DEFERRABLE;
ALTER TABLE egg ADD CONSTRAINT eggREFchicken
FOREIGN KEY (cID) REFERENCES chicken(cID)
INITIALLY DEFERRED DEFERRABLE;


SQL> INSERT INTO chicken VALUES(1, 2);
INSERT INTO chicken VALUES(1, 2)
*
ERROR at line 1:
ORA-02291: integrity constraint (U2.CHICKENREFEGG) violated - parent key not found

I am getting this error. Why?


Regards,
Mathew
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2007
Added on Nov 15 2007
2 comments
663 views