First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
SET serveroutput on
|
||||
|
||||
DECLARE
|
||||
|
||||
rs1 varchar2(255);
|
||||
rs2 varchar2(255);
|
||||
operatore varchar2(15);
|
||||
dir_out varchar2(255);
|
||||
num NUMBER(15,0);
|
||||
totale NUMBER(15,0);
|
||||
cod_dig varchar2(1);
|
||||
cod varchar2(4);
|
||||
file1 UTL_FILE.file_type;
|
||||
data_inizio date;
|
||||
data_fine date;
|
||||
data date;
|
||||
di date;
|
||||
di date;
|
||||
p varchar2(15):='&1';
|
||||
|
||||
--Numero di richieste ricevute dalla rete di distribuzione nel periodo di riferimento
|
||||
CURSOR cur_res(data_inizio date, data_fine date) is
|
||||
select olo.desc_olo,nvl(X.num,0)
|
||||
from mnp_olo_report olo, (
|
||||
select count(distinct msisdn) num , codice_operatore_donating cod
|
||||
from mnp_gestione_richiesta_rec
|
||||
where codice_operatore_recipient = 'TIMG'
|
||||
and dataricezionerichiesta >= trunc(data_inizio)
|
||||
and dataricezionerichiesta <= trunc(data_fine)
|
||||
group by codice_operatore_donating
|
||||
|
||||
) X
|
||||
where olo.flag_attivo = 1
|
||||
and olo.desc_olo <> 'TIMG'
|
||||
and olo.desc_olo = x.cod(+)
|
||||
order by olo.desc_olo;
|
||||
--------------------------------------------
|
||||
--INIZIO
|
||||
BEGIN
|
||||
if (p <> 'nullo')then
|
||||
dir_out:='&3';
|
||||
|
||||
else
|
||||
select recipient_out into dir_out
|
||||
from mnp_olo_report
|
||||
where desc_olo = 'MONIT';
|
||||
end if;
|
||||
|
||||
file1 := UTL_FILE.fopen (dir_out, 'TIM_to_AOM_NumeroRichiesteRicevute_'||to_char(sysdate,'yyyyMMdd')||'.csv', 'w');
|
||||
|
||||
BEGIN
|
||||
if (p <> 'nullo')then
|
||||
|
||||
data_inizio := to_date('&1','dd/mm/yyyy');
|
||||
data_fine := to_date('&2','dd/mm/yyyy');
|
||||
else
|
||||
if (to_char(sysdate, 'DD')<= '15') then
|
||||
data := add_months((trunc(sysdate)), -1);
|
||||
data_inizio := to_date('16/'|| to_char(trunc(data), 'mm/yyyy'),'dd/mm/yyyy');
|
||||
data_fine := last_day(trunc(data));
|
||||
else
|
||||
data_inizio := to_date('01/'|| to_char(trunc(sysdate), 'mm/yyyy'), 'dd/mm/yyyy');
|
||||
data_fine := to_date('15/'|| to_char(trunc(sysdate), 'mm/yyyy'), 'dd/mm/yyyy');
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
UTL_FILE.put_line (file1,'Numero di richieste ricevute dalla rete di distribuzione nel periodo di riferimento');
|
||||
UTL_FILE.put_line (file1,' ');
|
||||
UTL_FILE.put_line (file1,'Periodo dal '|| trunc(data_inizio) || ' al '|| trunc(data_fine));
|
||||
UTL_FILE.put_line (file1,' ');
|
||||
UTL_FILE.put_line (file1,'Operatore Recipient TIMG');
|
||||
UTL_FILE.put_line (file1,' ');
|
||||
|
||||
rs1:='';
|
||||
rs2:='';
|
||||
totale:=0;
|
||||
OPEN cur_res(data_inizio, data_fine);
|
||||
LOOP
|
||||
FETCH cur_res INTO operatore,num;
|
||||
EXIT WHEN cur_res%NOTFOUND;
|
||||
|
||||
rs1 := rs1 || operatore ||';';
|
||||
rs2 := rs2 || num ||';';
|
||||
totale := totale + num;
|
||||
END LOOP;
|
||||
CLOSE cur_res;
|
||||
|
||||
rs1:=rs1 ||'TOTALE'||';';
|
||||
rs2:=rs2 || totale ||';';
|
||||
UTL_FILE.put_line (file1,rs1);
|
||||
UTL_FILE.put_line (file1,rs2);
|
||||
UTL_FILE.fflush (file1);
|
||||
UTL_FILE.fclose (file1);
|
||||
|
||||
exception
|
||||
when others then
|
||||
DBMS_OUTPUT.PUT_LINE(sqlerrm);
|
||||
END;
|
||||
|
||||
end;
|
||||
/
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user