I often use the logic below to load data from a query into a table. First I try to insert the row, and if it violates the pk constraint of the table I do an update instead.

It seems that performance can be really slow when I'm dealing with a large number of updates. Maybe a factor of 10 longer than the case where it's mostly inserts. Is there a better way to perform this type of operation?

...
FOR some_cursor_rec IN some_cursor LOOP
INSERT INTO some_table(...
EXCEPTION WHEN OTHERS THEN
BEGIN
UPDATE some_table...
END;
COMMIT;
END LOOP;
...

Thanks