php-db | 2000121
Date: 12/12/00
- Next message: Guridi, Jose: "[PHP-DB] strange behavior of varchar2 in oracle"
- Previous message: Anthony Martin: "RE: [PHP-DB] <PK><FK>"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm attempting, for the first time, to make use of referential integrity,
but I'm getting an error. I realize this is nothing to do with PHP, but
maybe someone here can help. Thanks.
Warning: PostgreSQL query failed: ERROR: referential integrity violation -
key referenced from LessonsPages not found in Lessons
Here is the table's structures:
CREATE SEQUENCE "LessonsPages_id_seq";
CREATE TABLE "LessonsPages" (
"id" int4 DEFAULT nextval('"LessonsPages_id_seq"') NOT NULL,
"lid" int4 NOT NULL
REFERENCES "Pages"
ON DELETE CASCADE,
"pid" int4 NOT NULL
REFERENCES "Lessons"
ON DELETE CASCADE,
PRIMARY KEY ("lid", "pid")
);
CREATE SEQUENCE "Lessons_id_seq";
CREATE TABLE "Lessons" (
"id" int4 nextval('"Lessons_id_seq"') NOT NULL,
"page_name" char(64),
"summary_email" bool,
"order_num" int2,
PRIMARY KEY ("id")
);
CREATE SEQUENCE "Pages_id_seq";
CREATE TABLE "Pages" (
"id" int4 nextval('"Pages_id_seq"') NOT NULL,
"page_name" char(64),
"summary_email" bool,
"order_num" int2,
PRIMARY KEY ("id")
);
The error comes when:
INSERT INTO "Pages" (order_num) VALUES (1);
SELECT id FROM "Pages";
| id |
16
1 Row
INSERT INTO "Lessons" (lesson_name, order_num) VALUES ('test lesson', 2);
SELECT id FROM "Lessons";
| id |
9
1 Row
INSERT INTO "LessonsPages" (lid,pid) VALUES (9,16);
What am I doing wrong?
- - - - - - -
- - - - -
WARNING: Some experts believe that use of any keyboard may cause serious
injury.
Consult Users Guide.
dfunct <email protected>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Guridi, Jose: "[PHP-DB] strange behavior of varchar2 in oracle"
- Previous message: Anthony Martin: "RE: [PHP-DB] <PK><FK>"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

