Re: newbie question - delete before insert

From: Ashish Karalkar <ashish(dot)karalkar(at)netcore(dot)co(dot)in>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: newbie question - delete before insert
Date: 2010-11-20 09:58:47
Message-ID: 4CE79BD7.9030400@netcore.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/20/2010 02:43 PM, Thomas Kellerer wrote:
> Grant Mckenzie wrote on 20.11.2010 07:00:
>> How do people implement insert or upate ( otherwise known as upsert )
>> behaviour in postgres i.e. insert a row if it's key does not exist in
>> the database else update the existing row?
>>
>
> You can simply send the UPDATE, if nothing was updated, it's safe to
> send the INSERT
>
> Regards
> Thomas
>
>
>
something on the line of ....

http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html

*Example 38-2. Exceptions with UPDATE/INSERT*

--

With Regards
Ashish Karalkar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Radosław Smogura 2010-11-20 12:14:00 Re: The first dedicated PostgreSQL forum
Previous Message Thomas Kellerer 2010-11-20 09:13:07 Re: newbie question - delete before insert