Skip site navigation (1) Skip section navigation (2)

Re: Insert problem

From: "Jamie Tufnell" <diesql(at)googlemail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Insert problem
Date: 2008-03-10 00:14:12
Message-ID: b0a4f3350803091714n2b89425ev48410eb86451b973@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
On 3/9/08, A. R. Van Hook <hook(at)lota(dot)us> wrote:
> The script worked fine untill I tried in on the following entries:
>
> 1841 | 2 | 9228 : Caty Case : SO:Bra:.....
> 1841 | 3 | 9621 : Kelsie Greenlee : PROM.....
>
> 2072 | 3 | null : Cookie Jared Cook :..........
> 2072 | 4 | null : Cookie Jared Cook :........
> 2072 | 5 | null : Cookie Jared Cook :........
>
> insert into schItem (scid, value, iflag, outalts, sidate, istid)
>
> ERROR: duplicate key violates unique constraint "schitem_pkey"
>
> table defination
>
> create sequence schItem_item_seq
> create table schItem
> (scid int NOT NULL references schedule ON DELETE CASCADE,
> item int NOT NULL default nextval('schItem_item_seq'),

[snip]

It looks like there's already a row where scid=2072 and
item=nextval('schItem_item_seq').

Try:

SELECT setval('schItem_item_seq', (SELECT max(item)+1 FROM schItem));

And then run your query again.

Cheers,
J.

In response to

pgsql-sql by date

Next:From: Steve MidgleyDate: 2008-03-10 18:09:04
Subject: Re: Insert problem
Previous:From: A. R. Van HookDate: 2008-03-09 21:02:53
Subject: Insert problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group