PL/SQL MERGE STATEMENT. I need a count of both inserted and updated rows.
Posted on 2007-04-11
I have the following merge statement that either inserts a new record OR updates a record. Then it prints out the number of rows merged.
I want to be able to print out BOTH number of rows inserted and number of rows updated. Is there a way to do this, and how would it be done?
MERGE INTO dm_table dm
USING (SELECT *
FROM mytable WHERE status_ = c_load_stat_new) dmld
ON (dm.id= dmld.dm_physician_id)
WHEN MATCHED THEN
SET a =a1
WHEN NOT MATCHED THEN
dbms_output.put_line(to_char(SQL%ROWCOUNT) || ' rows merged.');