How about using a "
initially deferred" clause?
Example (What was first, the chicken or the egg?):
CREATE TABLE chicken(cID INT PRIMARY KEY,eID INT);
CREATE TABLE egg(eID INT PRIMARY KEY,cID INT);
Foreign keys:
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;
INITIALLY DEFERRED DEFERRABLE tells Oracle to do deferred constraint checking. For example, to insert (1, 2) into chicken and (2, 1) into egg, you use:
INSERT INTO chicken VALUES(1, 2);
INSERT INTO egg VALUES(2, 1);
COMMIT;
Ok, maybe you already knew that and I was just to lazy too read your code thoroughly

, but I just copied this out of somewhere and there you go...