pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Teemu Torma <teemu@torma.org>
To: pgsql-sql@postgresql.org
Subject: Re: duplicate key violates unique constraint
Date: Tue, 26 Feb 2008 16:17:39 +0100
Message-ID: <200802261617.39936.teemu@torma.org> (raw)
In-Reply-To: <014401c87887$a8fed450$3102a8c0@dream>
References: <014401c87887$a8fed450$3102a8c0@dream>

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



view thread (17+ messages)  latest in thread

Message-ID: <200802261617.39936.teemu@torma.org>
Permalink:  ../200802261617.39936.teemu@torma.org/
Also on:    postgresql.org/message-id/200802261617.39936.teemu@torma.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: teemu@torma.org
  Subject: Re: duplicate key violates unique constraint
  In-Reply-To: <200802261617.39936.teemu@torma.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox