Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Combine Multiple Merge statements into one?

sathya_mounikaOct 1 2013 — edited Oct 3 2013

Hi All,

I am stuck with a situation here that I never came across. I will try to depict in below. I am running it in Oracle 10g.

TABLE_A is empty before the start of the process. TABLE_B has a few million rows. Rest have few thousands.

INSERT INTO TABLE_A

SELECT * FROM TABLE_B;

MERGE INTO TABLE_A

USING TABLE_C

ON TABLE_A.PID = TABLE_C.PID

WHEN MATCHED

UPDATE

WHEN NOT MATCHED

INSERT;

MERGE INTO TABLE_A

USING TABLE_D

ON TABLE_A.PID = TABLE_D.PID

WHEN MATCHED

UPDATE

WHEN NOT MATCHED

INSERT;

MERGE INTO TABLE_A

USING TABLE_E

ON TABLE_A.PID = TABLE_E.PID

WHEN MATCHED

UPDATE

WHEN NOT MATCHED

INSERT;

due to the huge volume of data the merge statement had to deal with everytime it runs, it is consuming lot of time (hrs) to run. Is there a way to rewrite above merge sql's into one sql statement using outer joins? I tried a few approaches, but none seem to be practical. Please shed some light on the issue if you find a more straighter way to do the same.

Thanks

This post has been answered by SomeoneElse on Oct 1 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2013
Added on Oct 1 2013
4 comments
1,176 views