"on existing update" construct

Started by Dev Kumkarover 12 years ago7 messages
#1Dev Kumkar
devdas.kumkar@gmail.com

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

#2Daniel Farina
daniel@heroku.com
In reply to: Dev Kumkar (#1)
Re: "on existing update" construct

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.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Dev Kumkar
devdas.kumkar@gmail.com
In reply to: Daniel Farina (#2)
Re: "on existing update" construct

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:

Show quoted text

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.

#4Josh Berkus
josh@agliodbs.com
In reply to: Dev Kumkar (#1)
Re: "on existing update" construct

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Dev Kumkar
devdas.kumkar@gmail.com
In reply to: Josh Berkus (#4)
Re: "on existing update" construct

Please do not top-post on the PostgreSQL lists. See <

http://idallen.com/topposting.html&gt;

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!

#6Dev Kumkar
devdas.kumkar@gmail.com
In reply to: Dev Kumkar (#5)
Re: "on existing update" construct

Basically I was referring to this link http://mbk.projects.postgresql.org

Any suggestions here?

Thanks!

#7Craig Ringer
craig@2ndquadrant.com
In reply to: Dev Kumkar (#1)
Re: "on existing update" construct

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers