Thread: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error ator near "merge".
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error ator near "merge".
From
Vinodh NV
Date:
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)";
Re: Caused by: org.postgresql.util.PSQLException: ERROR: syntaxerror at or near "merge".
From
Alvaro Herrera
Date:
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