Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8C6FE2E0033 for ; Tue, 26 Feb 2008 12:05:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 78214-05 for ; Tue, 26 Feb 2008 12:05:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtpout24.attiva.biz (smtpout24.attiva.biz [85.37.16.25]) by postgresql.org (Postfix) with ESMTP id DC3E42E0030 for ; Tue, 26 Feb 2008 12:05:03 -0400 (AST) Received: from fbcmfe02b11.fbc.local ([192.168.30.92]) by smtpout24.attiva.biz with Microsoft SMTPSVC(6.0.3790.1830); Tue, 26 Feb 2008 17:05:01 +0100 Received: from dream ([88.34.161.130]) by fbcmfe02b11.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Tue, 26 Feb 2008 17:05:00 +0100 Message-ID: <016401c87891$58237950$3102a8c0@dream> Reply-To: "Shavonne Marietta Wijesinghe" From: "Shavonne Marietta Wijesinghe" To: "Teemu Torma" , References: <014401c87887$a8fed450$3102a8c0@dream> <200802261617.39936.teemu@torma.org> Subject: Re: duplicate key violates unique constraint Date: Tue, 26 Feb 2008 17:05:01 +0100 Organization: Studio FORM MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-OriginalArrivalTime: 26 Feb 2008 16:05:00.0512 (UTC) FILETIME=[56FDBE00:01C87891] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/202 X-Sequence-Number: 30293 Thank you. I tried as you said. But i get a ERROR: syntax error at or near "INSERT" at character 9 BEGIN INSERT INTO my_shevi values ('a', 4, 2, 2); EXCEPTION WHEN unique_violation THEN INSERT INTO my_shevi values ('a', 5, 2, 2); END; I don't see anything wrong with the code.. Shavonne ----- Original Message ----- From: "Teemu Torma" To: Sent: Tuesday, February 26, 2008 4:17 PM Subject: Re: [SQL] duplicate key violates unique constraint > On Tuesday 26 February 2008, Shavonne Marietta Wijesinghe wrote: >> During an "INSERT INTO" I get an "Error - duplicate key violates >> unique constraint...." >> >> Is there any way, that i can test the error. Something like this?? >> >> IF error = "duplicate key violates unique constraint" then >> Â Â do something >> else >> Â Â insert into >> end if > > insert into ...; > exception when unique_violation then > do something; > > Teemu > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings