Re: Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-27 Thread David G. Johnston
On Thursday, January 27, 2022, Anand Sowmithiran wrote: > > However, the MS SQL server MERGE command also does 'delete' using the > 'when not matched' clause, is there an equivalent ? > PostgreSQL does not have a merge command feature. Just the subset of behavior that is INSERT…on conflict

Re: Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-27 Thread Anand Sowmithiran
Thanks , that was helpful. I was not framing the right key words during my searches in SO! Using the xmax internal column, able to detect if the upsert did an Insert or Update. However, the MS SQL server MERGE command also does 'delete' using the 'when not matched' clause, is there an equivalent ?

Re: Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-26 Thread Justin Pryzby
On Thu, Jan 27, 2022 at 10:24:14AM +0530, Anand Sowmithiran wrote: > The INSERT...ON CONFLICT is used for doing upserts in one of our app. > Our app works with both MS SQL and Postgresql, based on customer needs. > > Unlike the MS SQL MERGE command's OUTPUT clause that gives the $action >

Re: Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-26 Thread Thomas Munro
On Thu, Jan 27, 2022 at 5:54 PM Anand Sowmithiran wrote: > Is there any workaround to get this info ? There's an undocumented trick: https://stackoverflow.com/questions/34762732/how-to-find-out-if-an-upsert-was-an-update-with-postgresql-9-5-upsert

Re: Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-26 Thread David G. Johnston
On Wednesday, January 26, 2022, Anand Sowmithiran wrote: > The INSERT...ON CONFLICT is used for doing upserts in one of our app. > Our app works with both MS SQL and Postgresql, based on customer needs. > > Unlike the MS SQL MERGE command's OUTPUT clause that gives the $action >

Output clause for Upsert aka INSERT...ON CONFLICT

2022-01-26 Thread Anand Sowmithiran
The INSERT...ON CONFLICT is used for doing upserts in one of our app. Our app works with both MS SQL and Postgresql, based on customer needs. Unlike the MS SQL MERGE command's OUTPUT clause that gives the $action