Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 582642E023C for ; Sun, 9 Mar 2008 18:03:01 -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 66459-01 for ; Sun, 9 Mar 2008 18:02:58 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from QMTA05.emeryville.ca.mail.comcast.net (qmta05.emeryville.ca.mail.comcast.net [76.96.30.48]) by postgresql.org (Postfix) with ESMTP id 4E4092E022D for ; Sun, 9 Mar 2008 18:02:58 -0300 (ADT) Received: from OMTA13.emeryville.ca.mail.comcast.net ([76.96.30.52]) by QMTA05.emeryville.ca.mail.comcast.net with comcast id z39H1Y00C17UAYkA50LL00; Sun, 09 Mar 2008 21:01:48 +0000 Received: from [192.168.1.6] ([69.242.166.153]) by OMTA13.emeryville.ca.mail.comcast.net with comcast id z92u1Y0043JuWql8Z00000; Sun, 09 Mar 2008 21:02:56 +0000 X-Authority-Analysis: v=1.0 c=1 a=t3_GrPcaxXGpN9Ljp-QA:9 a=SVCnzp4KF2TntGX_MSgA:7 a=Wi5h6IIXvrMlRWKYP52siz7r9iAA:4 a=si9q_4b84H0A:10 a=dJOLiP2OdrIA:10 a=PZVKwcGPaSIA:10 a=gi0PWCVxevcA:10 Message-ID: <47D4507D.8010709@lota.us> Date: Sun, 09 Mar 2008 16:02:53 -0500 From: "A. R. Van Hook" User-Agent: Thunderbird 1.5.0.12 (X11/20071019) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Insert problem Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/49 X-Sequence-Number: 30377 I have a table where some of the entries of should have been posted to the wrong cusid and item#: cusid | item# | 1747 | 149 | 9251 : Jonathon Krinke ....... 1747 | 150 | 10071 : Lindsey Steele ........ 1747 | 151 | 10187 : Lindsay Stapley ....... 1747 | 152 | 10188 : Amanda Goucher ........ 1888 | 0 | 10071 : PROM 75P1206 mi......... corrected: 1747 | 148 | 9250 : Jonathon Krinke ........ 1747 | 149 | 9251 : Jonathon Krinke ....... 1888 | 0 | 10071 : PROM 75P1206 mi...... 1888 | 1 | 10071 : Lindsey Steele 1888 | 2 | 10187 : Lindsay Stapley 1888 | 3 | 10188 : Amanda Goucher my correction script: 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) select 2072, i.value, i.iflag, i.outalts, i.sidate, i.istid from schItem i, schItem s where i.scid=1841 and i.item >= 3 and s.scid = 2072 group by i.value, i.iflag, i.outalts, i.sidate, i.istid, s.scid ERROR: duplicate key violates unique constraint "schitem_pkey" It seems I have something wrong with the select portion of the script but I can figure it out. Any idea?? thanks ps 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'), value text, iflag int, outalts int, sidate date, istid int references stock, primary key (scid, item)) -- Arthur R. Van Hook hook@lota.us avanhook3@comcast.net (816) 578-4704 - Home (816) 629-0071 Cell -- Arthur R. Van Hook hook@lota.us avanhook3@comcast.net (816) 578-4704 - Home (816) 629-0071 Cell