mintsii
asked on
PL/SQL MERGE STATEMENT. I need a count of both inserted and updated rows.
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
UPDATE
SET a =a1
WHEN NOT MATCHED THEN
INSERT
(a)
VALUES
(a1);
dbms_output.put_line(to_ch ar(SQL%ROW COUNT) || ' rows merged.');
--
COMMIT;
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
UPDATE
SET a =a1
WHEN NOT MATCHED THEN
INSERT
(a)
VALUES
(a1);
dbms_output.put_line(to_ch
--
COMMIT;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER