Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 21A7B2E01A7 for ; Sun, 9 Mar 2008 21:14:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 71834-04 for ; Sun, 9 Mar 2008 21:14:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.158]) by postgresql.org (Postfix) with ESMTP id 71FF42E019F for ; Sun, 9 Mar 2008 21:14:14 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id 22so1321160fge.23 for ; Sun, 09 Mar 2008 17:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=TPjnUeiJPm7IaUEy5ctUu1d1JGQFhXeaXiv7Xe4Kj8w=; b=ossJkojUHIx7H+wxXI+XuU/R6cX2theX22LjUvbW3rGA+++KLfhywWjVRDn7zx6B0RTBxwc0ZDS3zuKZLEm6aV0yCv3icvsZLPdkVQ/WhtjAuZ8j+5DZbGVkCYkWq+E1FP7QOfJ62Vz9x3yC0dCBu1mhG/eXUsXdJuOk5Abb24o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sqy8TVLmMqKGWIITcJL80XO4EwFgs9eOmAm1E9GTNVppcXrNnRNUL22lETzHmjkiTrQuGqrlagdT0RHH4IIMEqEysdItkELZd3T9ssuw/fDp1j1X1k43vtujYZvB+6FxAVvVvohzxsVrTPN2+TRGgkmFUwLSK8si5BNcOgwxeL8= Received: by 10.86.96.18 with SMTP id t18mr5605574fgb.13.1205108052829; Sun, 09 Mar 2008 17:14:12 -0700 (PDT) Received: by 10.86.4.15 with HTTP; Sun, 9 Mar 2008 17:14:12 -0700 (PDT) Message-ID: Date: Mon, 10 Mar 2008 00:14:12 +0000 From: "Jamie Tufnell" To: pgsql-sql@postgresql.org Subject: Re: Insert problem In-Reply-To: <47D4507D.8010709@lota.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47D4507D.8010709@lota.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200803/50 X-Sequence-Number: 30378 On 3/9/08, A. R. Van Hook 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.