Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 547D39FB47D for ; Tue, 20 Mar 2007 06:20:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 00504-05-2 for ; Tue, 20 Mar 2007 06:20:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from interscan.indicator.com (mail.indicator.be [193.121.199.3]) by postgresql.org (Postfix) with ESMTP id E85819FB54A for ; Tue, 20 Mar 2007 06:20:44 -0300 (ADT) Received: from webaccess.indicator.be ([10.100.1.7]) by interscan.indicator.com with InterScan Message Security Suite; Tue, 20 Mar 2007 10:07:44 +0100 Received: from DOMEXT-MTA by webaccess.indicator.bewith Novell_GroupWise; Tue, 20 Mar 2007 10:20:39 +0100 Message-Id: <45FFB56F.A3DD.0030.0@indicator.be> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Tue, 20 Mar 2007 10:20:32 +0100 From: "Bart Degryse" To: "remco lengers" , Subject: Re: ERROR: duplicate key violates unique constraint References: <32207abd0703200211l46acdab7p5a2d68d69ffc5b6c@mail.gmail.com> In-Reply-To: <32207abd0703200211l46acdab7p5a2d68d69ffc5b6c@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__Part0521B270.1__=" X-imss-version: 2.046 X-imss-result: Passed X-imss-approveListMatch: *@indicator.be X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.238 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO, HTML_MESSAGE, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200703/267 X-Sequence-Number: 27905 --=__Part0521B270.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Use INSERT INTO reference(reference_text, reference_type, Topic_Id) VALUES = (DEFAULT,'123','2',1);=20 instead. Since referencelist_nr is a serial PostgreSQL will provide the next free = integer itself. >>> "remco lengers" 2007-03-20 10:11 >>> Hi List, Its been a while since I worked with databases and I am running into the = following which I have not been able to find the root cause for: I have the follow SQL statement: INSERT INTO reference VALUES (DEFAULT,'123','2',1);=20 Which generates the following error:=20 "ERROR: duplicate key violates unique constraint "reference_pkey"" And the table definition looks like: CREATE TABLE reference ( referencelist_nr serial unique, =20 reference_text varchar(40) NOT NULL,=20 reference_type integer NOT NULL,=20 Topic_Id integer NOT NULL, PRIMARY KEY (referencelist_nr), FOREIGN KEY (Topic_Id) REFERENCES Topic (Topic_Id), FOREIGN KEY (reference_type) REFERENCES reference_type (reference_type_nr)= =20 ); It seems to me for some reason "DEFAULT" doesn't select the next SERIAL. If I run:=20 INSERT INTO reference VALUES (14,'123','2',1); 14 being the next free integer it works fine..... I have been adding data with "COPY" into this table....does that break = something? Your help/tips/insights are appreciated. Solaris 10/Postgresql 8.1.4 Regards, ..Remco=20 --=__Part0521B270.1__= Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Description: HTML
Use
INSERT INTO reference(reference_text, reference_type, Topic_Id) = VALUES (DEFAULT,'123','2',1);
instead.
Since referencelist_nr is a serial PostgreSQL will provide the next = free integer itself.


>>> "remco lengers" <pgsql@leng= ers.com> 2007-03-20 10:11 >>>
Hi List,

Its been a = while since I worked with databases and I am running into the following = which I have not been able to find the root cause for:

I have the = follow SQL statement:

INSERT INTO reference VALUES (DEFAULT,'123','2= ',1);

Which generates the following error:

"ERROR:  = duplicate key violates unique constraint "reference_pkey""

And the = table definition looks like:

CREATE TABLE reference (
referenceli= st_nr serial unique, 
reference_text varchar(40) NOT NULL, =
reference_type integer NOT NULL,
Topic_Id integer NOT NULL,
PRIM= ARY KEY (referencelist_nr),
FOREIGN KEY (Topic_Id) REFERENCES Topic = (Topic_Id),
FOREIGN KEY (reference_type) REFERENCES reference_type = (reference_type_nr)
);

It seems to me for some reason "DEFAULT" = doesn't select the next SERIAL.
If I run:

INSERT INTO reference = VALUES (14,'123','2',1);

14 being the next free integer it works = fine.....

I have been adding data with "COPY" into this table....doe= s that break something?

Your help/tips/insights are appreciated.
=
Solaris 10/Postgresql 8.1.4

Regards,

..Remco
=
--=__Part0521B270.1__=--