pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dinesh <dbhandary@mongonet.net>
To: Alex Hunsaker <badalex@gmail.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: error handling unique key constraint in pgsql
Date: Tue, 10 Jun 2008 14:54:55 -0700
Message-ID: <484EF82F.8080500@mongonet.net> (raw)
In-Reply-To: <34d269d40806101438k3fe3833k48ff9e0224b1cbee@mail.gmail.com>
References: <484EB14B.4010003@mongonet.net>
	<dcc563d10806101209x4edfd77dl28bf514a0742d845@mail.gmail.com>
	<484EE821.6090700@mongonet.net>
	<34d269d40806101438k3fe3833k48ff9e0224b1cbee@mail.gmail.com>

Great. That's what I was looking for. Thanks a lot guys.

Dinesh

Alex Hunsaker wrote:
> On Tue, Jun 10, 2008 at 2:46 PM, Dinesh <dbhandary@mongonet.net> wrote:
>   
>> Hi Scott,
>>
>> Thanks for your reply.
>>
>> Is there a built in exception in pl/pgsql ( similar to oracle's
>> |DUP_VAL_ON_INDEX ) that I can use?
>>
>> I ran into an unique situation a couple of days ago. Procedure that inserts
>> a new value into unique index column was called at the same time. I even
>> check if the value exist before inserting, but one of the instance of the
>> function gave me an unique constraint violation error.
>>
>> My code looks like this:
>>
>> select into var * from table;
>>
>> if not found then
>> insert into table
>> values (a);
>> end if;
>> |
>> I would imagine the postgres db would inherently handle situation like this,
>> but it did not.
>>
>> Thanks.
>>     
>
>
> See http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING,
> specifically  example Example 38-1.
>
>   




view thread (5+ messages)

Message-ID: <484EF82F.8080500@mongonet.net>
Permalink:  ../484EF82F.8080500@mongonet.net/
Also on:    postgresql.org/message-id/484EF82F.8080500@mongonet.net

 · 

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-admin@postgresql.org
  Cc: dbhandary@mongonet.net, badalex@gmail.com, scott.marlowe@gmail.com
  Subject: Re: error handling unique key constraint in pgsql
  In-Reply-To: <484EF82F.8080500@mongonet.net>

* 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