select * from master_tab;
PID SALES STATUS
-------- -------- ------
1 12 CURR
2 13 NEW
3 15 CURR
select * from delta_tab;
PID SALES STATUS
-------- -------- ------
2 24 CURR
3 0 OBS

4 42 CURR


merge into master_tab m
using delta_tab d
on (m.pid = d.pid)
when matched
then update set m.sales = m.sales+d.sales
, m.status = d.status
delete where m.status = 'OBS'
when not matched
then insert values (d.pid,d.sales,'NEW');
3 rows merged.



select * from master_tab;
PID SALES STATUS
-------- -------- ------
1 12 CURR
2 37 CURR
4 42 NEW