Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F40522E003D for ; Tue, 26 Feb 2008 12:22:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57172-06 for ; Tue, 26 Feb 2008 12:22:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id A589C2E0039 for ; Tue, 26 Feb 2008 12:22:52 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=crankycanuck.ca) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1JU2Zv-0002ur-U1 for pgsql-sql@postgresql.org; Tue, 26 Feb 2008 11:22:52 -0500 Received: by crankycanuck.ca (Postfix, from userid 1000) id B088950028; Tue, 26 Feb 2008 11:22:46 -0500 (EST) Date: Tue, 26 Feb 2008 11:22:46 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: duplicate key violates unique constraint Message-ID: <20080226162246.GA9865@crankycanuck.ca> References: <014401c87887$a8fed450$3102a8c0@dream> <200802261617.39936.teemu@torma.org> <016401c87891$58237950$3102a8c0@dream> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <016401c87891$58237950$3102a8c0@dream> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/203 X-Sequence-Number: 30294 On Tue, Feb 26, 2008 at 05:05:01PM +0100, Shavonne Marietta Wijesinghe wrote: > Thank you. I tried as you said. But i get a ERROR: syntax error at or near > "INSERT" at character 9 > I don't see anything wrong with the code.. Well, except that there's no "EXCEPTION" statement in SQL? I think your correspondent was intending for this to be programmatic. You can do what you want with a subtransaction, though. Look into savepoints in the manual. A