pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
merge statement gives error
2+ messages / 2 participants
[nested] [flat]

* merge statement gives error
@ 2018-02-26 15:02  Abhra Kar <abhra.kar@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Abhra Kar @ 2018-02-26 15:02 UTC (permalink / raw)
  To: pgsql-general

Hi,

       Trying to execute the following statement ----


merge into ABC as n using dual on (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].

Thanks

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: merge statement gives error
@ 2018-02-26 15:22  Thomas Kellerer <spam_eater@gmx.net>
  parent: Abhra Kar <abhra.kar@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas Kellerer @ 2018-02-26 15:22 UTC (permalink / raw)
  To: pgsql-general

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. 






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-02-26 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 15:02 merge statement gives error Abhra Kar <abhra.kar@gmail.com>
2018-02-26 15:22 ` Thomas Kellerer <spam_eater@gmx.net>

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