Hi to everybody,
why is the following code extremly slow in execution and
how can it be done better ? en is 50000. I need to now for
each uzsid in the table uzscontrol whether it shows up in
at least in one of the three tables and to mark it, if it does
not.
declare en number(8);
em number(8);
m1 number(8);
m2 number(8);
m3 number(8);
m4 number(8);
a1 char(6);
begin
select count(*) into en from uzscontrol;
for em in 1..en loop
select uzsid into a1 from uzscontrol where uzsnm=em;
select count(*) into m1 from uzsfrei where uzsid=a1;
select count(*) into m2 from uzsbt where uzsid=a1;
select count(*) into m3 from uzsht where uzsid=a1;
m4 := m1 + m2 + m3;
if m4 < 1 then update uzscontrol set uzsnm=0 where uzsnm=em;
end if;
end loop;
end;
/
quit;