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

2018-03-07 Thread Alvaro Herrera
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 Herrerahttps://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

2018-03-07 Thread Vinodh NV
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?

Thanks,
Vinodh.