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!

Using Merge instead of Update

CrackerJackBobFeb 9 2015 — edited Feb 9 2015

Hi all,

I have a pre-existing table and my update statement is taking a really long time.  So I'm switching to using Merge instead.  My problem is the Merge statement below is updating the entire table.  I only want it to update the remaining rows which have a null "id1" value.  So I only want it to update a small subset of rows. 

Trying to update table1 below:

merge into table1 x

using (select *

          from table2

          where model='Acura')  y

on (x.account_no = y.account_no)

when matched then update set x.id1 = y.id1

where x.id1 is null;            -- I only want to update rows which have a null value in field id1

commit;

Any help would be appreciated.  Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 9 2015
Added on Feb 9 2015
13 comments
1,557 views