Foreign Key Problem

From: Lola Lee <lola(at)his(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Foreign Key Problem
Date: 2003-12-27 00:53:52
Message-ID: p06020403bc1284a8e630@[192.168.2.103]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm using PostgreSQL 7.4, and I have two tables, which I created as follows:

CREATE TABLE needlestyle (
needle_style_id SERIAL,
needle_style_desc varchar(50) NULL,
needle_style_lud timestamp NULL,
PRIMARY KEY (needle_style_id)
);

CREATE TABLE needles (
needles_id SERIAL,
needle_style_id int NULL,
needle_mm decimal(5,2) NULL,
needle_length varchar(20) NULL,
needle_lud timestamp NULL,
PRIMARY KEY (needles_id),
FOREIGN KEY (needles_id)
REFERENCES accessory,
FOREIGN KEY (needle_style_id)
REFERENCES needlestyle
);

I filled the needlestyle table with three records. Then I tried to
run the following insert via phpPgAdmin and got the following error
message:

ERROR: insert or update on table "needles" violates foreign key constraint "$1"

In statement:
INSERT INTO "needles" ("needles_id", "needle_style_id", "needle_mm",
"needle_length", "needle_lud") VALUES
(nextval('public.needles_needles_id_seq'::text), '1', '2.25', '24"',
NULL)

What could be the problem?

--

Lola - mailto:lola(at)his(dot)com
http://www.lolajl.net | Blog at http://www.lolajl.net/blog/
Check out this blog: http://www.denbeste.nu
I'm in Bowie, MD, USA, halfway between DC and Annapolis.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-12-27 03:53:31 Re: Foreign Key Problem
Previous Message Tom Lane 2003-12-26 23:09:46 Re: Why should my rule be conditional?