Re: [SQL] duplicate key violates unique constraint

2008-02-26 Thread Teemu Torma
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


Re: [SQL] duplicate key violates unique constraint

2008-02-26 Thread Teemu Torma
On Tuesday 26 February 2008, Andrew Sullivan wrote:
> Well, except that there's no "EXCEPTION" statement in SQL?  I think
> your correspondent was intending for this to be programmatic.

I was thinking pl/pgsql.  

Teemu

---(end of broadcast)---
TIP 6: explain analyze is your friend