logo       
Google Custom Search
    AddThis Social Bookmark Button

Foreign Key Problem: msg#00233

Subject: Foreign Key Problem
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@xxxxxxx
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.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faqs/FAQ.html




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>