pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Vinodh NV <linktovinodh@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "merge".
Date: Wed, 7 Mar 2018 06:34:44 -0300
Message-ID: <20180307093444.upjdj2moqep46a6u@alvherre.pgsql> (raw)
In-Reply-To: <CAMBHpRjk1OxbYDRw1-cs_8LyKJ23LrXuiitmqaVJLJBJ7ckKvw@mail.gmail.com>

Vinodh NV wrote:
> Sir,
> 
> I am facing the error Caused by: org.postgresql.util.PSQLException: ERROR:
> syntax error at or near "merge". when I execute the below  query in
> postgres database. The same works fine in Oracle.
> 
> merge into net n using dual on (n.id=:id) when matched then update set
> Status=:status, lastStatusDate=:lastStatusDate, errorMessage=:errorMessage,
> errorDetails=:errorDetails when not matched then insert (id,Status,
> lastStatusDate, errorMessage, errorDetails) values
> (:id,:status,:lastStatusDate,:errorMessage,:errorDetails)";
> 
> 
> Can you please let me know how to resolve it?

Easy -- just don't use merge with Postgres, as it doesn't support MERGE
yet.  There's work ongoing to support it, but it will appear in Postgres
11 at the earliest.

There exists a nonstandard command INSERT ON CONFLICT DO UPDATE which
would probably be useful.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (2+ messages)

Message-ID: <20180307093444.upjdj2moqep46a6u@alvherre.pgsql>
Permalink:  ../20180307093444.upjdj2moqep46a6u@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180307093444.upjdj2moqep46a6u@alvherre.pgsql

 · 

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: alvherre@2ndquadrant.com, linktovinodh@gmail.com
  Subject: Re: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "merge".
  In-Reply-To: <20180307093444.upjdj2moqep46a6u@alvherre.pgsql>
  References: <CAMBHpRjk1OxbYDRw1-cs_8LyKJ23LrXuiitmqaVJLJBJ7ckKvw@mail.gmail.com> <20180307093444.upjdj2moqep46a6u@alvherre.pgsql>

* 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