Re: Implementing replace function - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Implementing replace function
Date
Msg-id iajf5l$bpp$1@dough.gmane.org
Whole thread Raw
In response to Implementing replace function  (Alexander Farber <alexander.farber@gmail.com>)
Responses Re: Implementing replace function  (Alexander Farber <alexander.farber@gmail.com>)
Re: Implementing replace function  (Matthieu Huin <matthieu.huin@wallix.com>)
List 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

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Implementing replace function
Next
From: Alexander Farber
Date:
Subject: Re: Implementing replace function