Is it possible to move rows from a source table to a destination table and then deleting the same rows from the source table in one statement ?
Something like this would be ideal, but I know "DELETE" cannot be use in "WHEN NOT MATCHED" clause... any suggestion please?
MERGE INTO destination_table d
USING (select *
from source_table
where conditions ) s
ON (s.ID = d.ID)
WHEN NOT MATCHED THEN
INSERT (field1_d, field2_d)
VALUES (fields_d, field2_s)
DELETE WHERE 1 = 1;
Thanks