Re: how to do merge in postgres ("with upsert as" not supported)

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: how to do merge in postgres ("with upsert as" not supported)
Date: 2015-02-27 08:53:38
Message-ID: mcpbaj$clo$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tong Michael schrieb am 26.02.2015 um 21:23:
>
> hey, guys, I came across a merge statement when I'm trying to convert stored procedures from Mysql to Postgres:____
>
> __ __
>
> merge into db.ChargePeriod d____
> using (____
> select ba.ClientID____
> ...
> ...

That can't be MySQL - MySQL does not have a MERGE statement.
That looks much more like SQL Server's T-SQL (MERGE, @ style variables, convert() function...)

Here are several ways to do it: http://stackoverflow.com/q/1109061/330315

> I saw some people use "with upsert as", but my pgAdmin version(1.8) doesn't support it.

pgAdmin supports whatever your Postgres version supports.
All supported/maintained Postgres versions support common table expressions.

What exactly do you mean with "doesn't support it"? What was the exact SQL statement you tried?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2015-02-27 08:55:48 Re: Regarding "Point-in-time Recovery" feature
Previous Message Jim Nasby 2015-02-27 08:52:34 Re: Re: [pgadmin-support] Issue with a hanging apply process on the replica db after vacuum works on primary