pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: merge statement gives error
Date: Mon, 26 Feb 2018 16:22:09 +0100
Message-ID: <a209d716-1699-8ab1-765d-3efc274a458e@gmx.net> (raw)
In-Reply-To: <CAFNULEdVuT0WmCqM15_oOsuW3CS9g1oPdQQ8=MW+hH+-hvJkQQ@mail.gmail.com>
References: <CAFNULEdVuT0WmCqM15_oOsuW3CS9g1oPdQQ8=MW+hH+-hvJkQQ@mail.gmail.com>

Abhra Kar schrieb am 26.02.2018 um 16:02:
> Hi,
> 
>        Trying to execute the following statement ---- 
> 
> 
> merge into ABC as n using dual on (n.id <http://n.id>=123)
> 
> when matched update set aaa=222, bbb=333
> 
>  when not matched insert (id, aaa) values (NEXTVAL(id),555);
> 
> 
> 
> but gives syntax error.What should be the proper syntax[ Parameter values are properly passed based on data type].

There is no MERGE statement in Postgres (there might be in Postgres 11, but not currently). 

You will need to use INSERT ON CONFLICT instead. 






view thread (2+ messages)

Message-ID: <a209d716-1699-8ab1-765d-3efc274a458e@gmx.net>
Permalink:  ../a209d716-1699-8ab1-765d-3efc274a458e@gmx.net/
Also on:    postgresql.org/message-id/a209d716-1699-8ab1-765d-3efc274a458e@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: merge statement gives error
  In-Reply-To: <a209d716-1699-8ab1-765d-3efc274a458e@gmx.net>
  References: <CAFNULEdVuT0WmCqM15_oOsuW3CS9g1oPdQQ8=MW+hH+-hvJkQQ@mail.gmail.com> <a209d716-1699-8ab1-765d-3efc274a458e@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox