Re: multi-column primary key insert error ('duplicate'

From: Darren Ferguson <darren(at)crystalballinc(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: multi-column primary key insert error ('duplicate'
Date: 2002-08-05 11:47:53
Message-ID: Pine.LNX.4.44.0208050746590.8768-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You have put a unique constraint on the column id so when you put two
identical id's into the system it will complain

You will have to remove the unique from the id and then you will be fine

HTH

On Mon, 5 Aug 2002, Jean-Christian Imbeault wrote:

> I have the following table where I want to use two columns as the primary:
>
> create table MOVIES (
>
> id char(12) unique references PRODUCTS,
> volume_id int2 not null default 1,
> label_id integer references LABELS(id),
> length int2 not null,
>
> primary key(id, volume_id)
> );
>
>
> However when I try the following:
>
> insert into movies values('589000901097','1','1','1');
> insert into movies values('589000901097','2','1','1');
>
> I get this error:
>
> ERROR: Cannot insert a duplicate key into unique index movies_id_key
>
> I thought I had defined the primary key to span two columns ... the data
> in the first two columns is not a duplicate...
>
> What did I miss?
>
> Thanks!
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
Darren Ferguson

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christian Ullrich 2002-08-05 11:57:02 Re: multi-column primary key insert error ('duplicate' complaint)
Previous Message m.malicky 2002-08-05 11:35:54 Problems with ODBC