1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
DECLARE
CURSOR c1 IS
select arfcext,count(arfcext) as NB
from v5.intart
group by arfcext order by NB desc;
TYPE tableau_numerique IS TABLE OF NUMBER(9) INDEX BY BINARY_INTEGER;
Tab tableau_numerique;
indice NUMBER(2);
i number (9);
j number (9);
min_val number (9);
min_ind number (9);
compt number (9);
BEGIN
DBMS_OUTPUT.ENABLE( 1000000 ) ;
indice :=&1;
i :=0;
min_val:=0;
min_ind:=0;
compt:=0;
for j in 0..indice-1 loop
Tab(j):=0;
end loop;
dbms_output.put_line( 'Indice de // :'||indice);
FOR r1 IN c1 LOOP
if compt > 5000 then
min_ind:=0;
min_val:=Tab(0);
for j in 1..indice-1 loop
-- dbms_output.put_line( 'Indice val // :'||Tab(j)|| ' et min'||min_val);
if Tab(j) < min_val then
min_val:=Tab(j);
min_ind:=j;
end if;
end loop;
compt:=0;
COMMIT;
end if;
Tab(min_ind):=Tab(min_ind) + r1.NB;
compt := compt + r1.NB ;
update v5.intart set ARFUTIL =min_ind where arfcext=r1.arfcext;
END LOOP;
for j in 0..indice loop
dbms_output.put_line( 'Tab :'||Tab(j));
end loop;
end;
/ |
Partager