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
|
function ft_quartsaffect (p_datedeb varchar2,p_datefin varchar2) return t_quarts_table as
qtable t_quarts_table;
qcoll t_quarts_col;
v_datdeb varchar2(10);
v_datfin varchar2(10);
cursor c_quarts is
select hdebq from
(select to_char(trunc(to_date(hdeb,'hh24mi'),'HH')+(15*floor(to_char( trunc(to_date(hdeb,'hh24mi'),'MI'),'MI')/15))/1440,'hh24mi') hdebq
from plpacti
where dat between v_datdeb and v_datfin
)
group by hdebq order by hdebq;
r_quarts c_quarts%ROWTYPE;
begin
v_datdeb := to_char(to_date(p_datedeb,'YYYYMMDD'),'DD/MM/YYYY');
v_datfin := to_char(to_date(p_datefin,'YYYYMMDD'),'DD/MM/YYYY');
qtable := t_quarts_table();
Open c_quarts;
loop
fetch c_quarts into r_quarts;
exit when c_quarts%notfound;
-- Utilisation de Bulk Collect pour alimenter la table retournée par la fonction
select t_quarts_col(dat , r_quarts.hdebq , codelieu , codequal , count(matri))
bulk collect into qtable
from plpacti
where ((r_quarts.hdebq between hdeb and hfin) and (r_quarts.hdebq+14 between hdeb and hfin)) and codequal <> ' '
and dat between v_datdeb and v_datfin
group by dat, codelieu, codequal
order by dat,r_quarts.hdebq;
end loop;
close c_quarts;
return qtable;
end;
/ |
Partager