Re: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "merge".

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Vinodh NV <linktovinodh(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "merge".
Date: 2018-03-07 09:34:44
Message-ID: 20180307093444.upjdj2moqep46a6u@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Arup Rakshit 2018-03-07 10:27:30 Re: help to query json column
Previous Message Vinodh NV 2018-03-07 09:26:32 Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "merge".