Hello
I am using following procedure to update MASTER table from TEMP table
it takes 5 to 6 hrs to execute.
Can you please help me to optimise time.
TABLES USED :
TEMP : select in CURSOR (COUNT: 1.5 CR)
MASTER : to update from TEMP table using FOR LOOP (COUNT : 3 CR)
ERROR_LOG : LOG error occured in UPDATE
Field Datatype details :ID1 : Number
ID2 : Varchar2
ID3 : Varchar2
Create or Replace procedure PROC_UPDATION (updbatch number) is
l_rows_affacted NUMBER := 0;
l_Total_rows_affacted NUMBER := 0;
l_Totrec NUMBER:=0;
str varchar2(255);
CURSOR temp_cur IS
SELECT ID1,ID2,ID3 from TEMP;
BEGIN
FOR temp_rec in temp_cur LOOP
DECLARE
updexception Exception;
BEGIN
if temp_rec.ID1 is NULL then
raise updexception;
end if;
str:='update master set ID1 ='|| temp_rec.ID1 ||' where ID2 ='''|| ID2 ||''' and ID3='''|| ID3 ||'''';
execute immediate str;
l_rows_affacted := SQL%ROWCOUNT; EXCEPTION
WHEN updexception then
l_Total_rows_affacted:=l_Total_rows_affacted -1;
insert into error_log values(sysdate,'UPDATE FAILED',LOG_SEQ.NEXTVAL);
commit;
END;
END LOOP;
EXCEPTION
when others then
insert into error_log values(sysdate,str,LOG_SEQ.NEXTVAL);?commit;
END;
/
[edit]SHOUTING removed, Code block added - OriginalGriff[/edit]