Re: On duplicate ignore

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: gnanam(at)zoniac(dot)com
Cc: Atul Goel <Atul(dot)Goel(at)iggroup(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: On duplicate ignore
Date: 2012-01-18 13:17:38
Message-ID: CAAfz9KPoK5B=NCKKCmbH6KJcgr7jtvZDxaU4r-HPg9eXhcfX1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey Gnanakumar,

2012/1/18 Gnanakumar <gnanam(at)zoniac(dot)com>

> > Just create a unique index on EMAIL column and handle error if it comes
>
> Thanks for your suggestion. Of course, I do understand that this could be
> enforced/imposed at the database-level at any time. But I'm trying to find
> out whether this could be solved at the application layer itself. Any
> thoughts/ideas?
>
Exactly at the application level you just need to ignore
an unique constraint violation error reported by the backend.
You may also wrap INSERT statement in the PL/pgSQL
function or in the DO statement and catch the exception
generated by the backend.

// Dmitriy.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message salah jubeh 2012-01-18 13:48:46 Table permessions
Previous Message Gnanakumar 2012-01-18 12:58:52 Re: On duplicate ignore