Re: Implementing replace function

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Implementing replace function
Date: 2010-10-31 10:07:51
Message-ID: iajf5l$bpp$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Farber wrote on 31.10.2010 09:22:
> Hello Postgres users,
>
> to mimic the MySQL-REPLACE statement I need
> to try to UPDATE a record and if that fails - INSERT it.
>

There is actually an example of this in the PG manual ;)

http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE

Here is another solution based on triggers:
http://database-programmer.blogspot.com/2009/06/approaches-to-upsert.html

Regards
Thomas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2010-10-31 10:36:44 Re: Implementing replace function
Previous Message Pavel Stehule 2010-10-31 10:00:02 Re: Implementing replace function