Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 4EB669FB416 for ; Tue, 20 Mar 2007 06:11:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 11003-04-2 for ; Tue, 20 Mar 2007 06:11:39 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238]) by postgresql.org (Postfix) with ESMTP id D16969FB42B for ; Tue, 20 Mar 2007 06:11:42 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id i28so1680240wxd for ; Tue, 20 Mar 2007 02:11:42 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=rJrmQ3C86pBLnbzDoGIGbQ2kaAludSAHhg7YSR9VV6KNzRQcTL39hwrli5yCS0gZtWgtVVBfXy9jB6tv+YzOAehTsqJ9Sx+KjFrtKfKdq6VOiBIdTcG436yrbCMW/EPNv/jNdWJWwpKmVWjONFkpwUykgg2/x5LPUPfDJn3qFdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=UGCt0kNa7cCrg3ZmcvN4qmojnEom/NzZu0xF9EmI1XQlektAPgQVZ1dzLU90szClfY2ywkw0yut5Ta6gvAvznyShCJ9uODMn1t0QVuds5YSLnNygvUMfMzwRzdwkZXMF38Hfa5k/Ez3z+vdGVTaUmTXfEnowumZjXrByHqym97g= Received: by 10.70.44.4 with SMTP id r4mr9517514wxr.1174381901996; Tue, 20 Mar 2007 02:11:41 -0700 (PDT) Received: by 10.115.76.4 with HTTP; Tue, 20 Mar 2007 02:11:41 -0700 (PDT) Message-ID: <32207abd0703200211l46acdab7p5a2d68d69ffc5b6c@mail.gmail.com> Date: Tue, 20 Mar 2007 10:11:41 +0100 From: "remco lengers" To: pgsql-sql@postgresql.org Subject: ERROR: duplicate key violates unique constraint MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_130234_20319974.1174381901895" X-Google-Sender-Auth: 246f363f2be8a99d X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/265 X-Sequence-Number: 27903 ------=_Part_130234_20319974.1174381901895 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ( referencelist_nr serial unique, reference_text varchar(40) NOT NULL, reference_type integer NOT NULL, 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) ); 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....does that break something? Your help/tips/insights are appreciated. Solaris 10/Postgresql 8.1.4 Regards, ..Remco ------=_Part_130234_20319974.1174381901895 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 (
referencelist_nr serial unique, 
reference_text varchar(40) NOT NULL,
reference_type integer NOT NULL,
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)
);

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....does that break something?

Your help/tips/insights are appreciated.

Solaris 10/Postgresql 8.1.4

Regards,

..Remco
------=_Part_130234_20319974.1174381901895--