Skip site navigation (1) Skip section navigation (2)

referential integrity error

From: Matej HollĂ˝ <h(dot)matej(at)krs(dot)sk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: referential integrity error
Date: 2002-06-11 11:12:43
Message-ID: 3D05DB2B.8050509@krs.sk (view raw or flat)
Thread:
Lists: pgsql-bugs
/*
  If a table contains two or more foreign keys referencing the same
  table and they reference the same record in the other table, the
  record's primary key cannot be changed even if the keys have the
  "ON UPDATE CASCADE" clause (see example below). It will say that
  "referential integrity error - key referenced from `table' not found
  in `table'".
*/

CREATE TABLE "Bug1" (
  "ID" INT4,
  "Description" TEXT NOT NULL,
  PRIMARY KEY("ID")
);
CREATE TABLE "Bug2" (
  "ID" INT4,
  "Source" INT4 NOT NULL
    REFERENCES "Bug1" ON UPDATE CASCADE ON DELETE NO ACTION,
  "Destination" INT4 NOT NULL
    REFERENCES "Bug1" ON UPDATE CASCADE ON DELETE NO ACTION,
  "Description" TEXT NOT NULL,
  PRIMARY KEY ("ID")
);
INSERT INTO "Bug1" VALUES (1,'Place');
INSERT INTO "Bug2" VALUES (10,1,1,'Move from Place to Place');
UPDATE "Bug1" SET "ID"=2 WHERE "ID"=1;



Responses

pgsql-bugs by date

Next:From: Lee KindnessDate: 2002-06-11 11:40:14
Subject: Re: Bug #640: ECPG: inserting float numbers
Previous:From: Bruce MomjianDate: 2002-06-11 10:58:54
Subject: Re: Bug #640: ECPG: inserting float numbers

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group