Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 14th, 2008, 01:05 PM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default Update statment with Exists and inner join, need tuning or alternative

This is the query I have to update a column in one table, by comparing 2 of its columns to with the columns of another table. The WIE_Physician table has 1655 records, hence the loop, and the temp_fact has just over 1million records. This query takes too long, can someone please help.

Thanks in advance
Leigh

begin
for i in 1..1655 loop

UPDATE temp_fact t SET SUR_ID_WIEPHYSICIAN = i where exists
(select SUR_ID_WIEPHYSICIAN from wie_physician c where c.STRPHYSICIAN_NO = t.STRPHYSICIAN_NO
and c.STRPHYSICIAN_NAME = t.STRPHYSICIAN_NAME and c.SUR_ID_WIEPHYSICIAN = i);

end loop;
end;
/
Reply
  #2  
Old August 14th, 2008, 06:09 PM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: India
Age: 24
Posts: 2,016
Default

Your code is incorrect.If the WHERE condition satisfies then all the 1 million records will be updated with current value of "i".

Instead of using EXIST, use the Joins to update that particular record and not all of them
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles