I am trying to perform upsert using merge operator , soon enough realised postgres does not have same merge statement like SQL Server, and multiple posts are referring to "insert on conflict" statement instead to simulate.
trying to simulate below in postgresSQL - can you please help, as I dont see any examples :
MERGE target_table USING source_table
ON merge_condition
WHEN MATCHED
THEN update_statement
WHEN NOT MATCHED
THEN insert_statement
WHEN NOT MATCHED BY SOURCE
THEN DELETE;
I have below datasets - Can you please point how to do this in postgres using "insert on conflict" or any other way;
TabA
==============
id | Val
------------
1 | 20
3 | 30
5 | 30
TabB
id | Val
------------
3 | 40
6 | 50