Re: duplicate key violates unique constraint

From: Teemu Torma <teemu(at)torma(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: duplicate key violates unique constraint
Date: 2008-02-26 15:17:39
Message-ID: 200802261617.39936.teemu@torma.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Shavonne Marietta Wijesinghe 2008-02-26 16:05:01 Re: duplicate key violates unique constraint
Previous Message TJ O'Donnell 2008-02-26 14:56:23 Re: Deploying PostgreSQL on virtualized hardware