DEFERRABLE constraints - error
508936Nov 15 2007 — edited Nov 15 2007Hi,
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