Re: upsert functionality

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: upsert functionality
Date: 2013-05-16 06:52:54
Message-ID: kn1vlk$ef4$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sajeev Mayandi, 16.05.2013 07:01:
> Hi,
>
> Our company is planning to move to postreSQL. We were initially using
> sybase where upsert functionality was available using "insert on
> existing update" clause. I know there multiple ways to fix this
> using RULE or separate function in postgresql. But I would like to
> know which version of postgresql has support for upsert planned using
> an official syntax. I have postgresql 9.2 which does not have this
> feature, if its planned in near future, I would rather wait to
> migrate to PostgreSQL.
>

You can use writeable CTEs for this purpose.

There are several examples out there:

http://www.xzilla.net/blog/2011/Mar/Upserting-via-Writeable-CTE.html
http://www.depesz.com/2011/03/16/waiting-for-9-1-writable-cte/
http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/

http://stackoverflow.com/a/8702291/330315

Regards
Thomas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eduardo Morrás 2013-05-16 08:47:07 Re: Best way to reduce server rounds getting big BLOBs
Previous Message Sajeev Mayandi 2013-05-16 05:01:41 upsert functionality