Обсуждение: "on existing update" construct

Поиск
Список
Период
Сортировка

"on existing update" construct

От
Dev Kumkar
Дата:
Hello,

Is there an alternative of Sybase "on existing update" construct in pgsql.

"ON DUPLICATE KEY UPDATE" doesn't work.

Thanks in advance!

Regards - Dev

Re: "on existing update" construct

От
Daniel Farina
Дата:
On Wed, May 15, 2013 at 11:44 AM, Dev Kumkar <devdas.kumkar@gmail.com> wrote:
> Hello,
>
> Is there an alternative of Sybase "on existing update" construct in pgsql.
>
> "ON DUPLICATE KEY UPDATE" doesn't work.
>
> Thanks in advance!

No, you'll have to either handle this in the application or use a
stored procedure at this time.  The omission of such a construct from
psql's "\h" command and the manual is not in error.



Re: "on existing update" construct

От
Dev Kumkar
Дата:
Well ya, stored procedure also was thinking about pre-insert trigger.

Am sure folks here must have gone thru this and had alternatives. Also was reading about merge_by_key.

On Wed, May 15, 2013 at 12:51 PM, Daniel Farina <daniel@heroku.com> wrote:
On Wed, May 15, 2013 at 11:44 AM, Dev Kumkar <devdas.kumkar@gmail.com> wrote:
> Hello,
>
> Is there an alternative of Sybase "on existing update" construct in pgsql.
>
> "ON DUPLICATE KEY UPDATE" doesn't work.
>
> Thanks in advance!

No, you'll have to either handle this in the application or use a
stored procedure at this time.  The omission of such a construct from
psql's "\h" command and the manual is not in error.

Re: "on existing update" construct

От
Josh Berkus
Дата:
On 05/15/2013 02:22 PM, Dev Kumkar wrote:
> Well ya, stored procedure also was thinking about pre-insert trigger.
> 
> Am sure folks here must have gone thru this and had alternatives. Also was
> reading about merge_by_key.

It's been on the TODO list forever.  It's harder to implement well than
you would think.


-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



Re: "on existing update" construct

От
Dev Kumkar
Дата:
> Please do not top-post on the PostgreSQL lists. See <http://idallen.com/topposting.html>
> Also, note that pgsql-hackers is entirely the wrong list for this sort of question. You should have been asking on pgsql-general.
Apologies for top-post!
Well I thought pgsql-hackers will suggest some new solution was just going by the description of mailing-list. Its worth looking into http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-postgresql

Let me know and I will post this question on pgsql-general.

> It's been on the TODO list forever.  It's harder to implement well than
> you would think.
Yes, I think it be nice to see this in one of the upcoming releases.

Thanks!

Re: "on existing update" construct

От
Dev Kumkar
Дата:
<div dir="ltr">Basically I was referring to this link <a href="http://mbk.projects.postgresql.org"
rel="nofollow">http://mbk.projects.postgresql.org</a><br/><br />Any suggestions here?<br /><br />Thanks!<br /></div> 

Re: "on existing update" construct

От
Craig Ringer
Дата:
On 05/16/2013 02:44 AM, Dev Kumkar wrote:
> Hello,
> 
> Is there an alternative of Sybase "on existing update" construct in pgsql.

No.

See:

http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services