106 lines
3.6 KiB
SQL
106 lines
3.6 KiB
SQL
-- [ ADBCFIN01 ]
|
|
--Esito Acquisizione flussi dai Sistemi Esterni
|
|
SET serveroutput on
|
|
|
|
declare
|
|
valore varchar2(255);
|
|
data_val date;
|
|
file1 UTL_FILE.file_type;
|
|
freq varchar2(255):='&1';
|
|
|
|
cursor cur_valore is
|
|
select attr,val,free||decode(n,0,null,1,null,' ('||n||' volte)') as free,data_val
|
|
from(
|
|
select attr,val,free,max(data_val) as data_val,count(*) as n
|
|
from (
|
|
select decode(e.id_flusso, -- file con nome corretto caricati completamente o in parte o non caricati
|
|
10,'Validazione CO',
|
|
11,'Validazione CO',
|
|
16,'Validazione BU')||'-:-'||
|
|
decode(e.id_flusso,
|
|
10,'CCRM',
|
|
11,'CCRM',
|
|
16,'BIT')||'-:-'||
|
|
a.descrizione as attr,
|
|
b.tipo_evento as val,
|
|
c.descrizione as free,
|
|
sysdate as data_val
|
|
from mnp_evento_governance a, mnp_processo_log b, mnp_anagrafica_log c, mnp_anagrafica_processo d, mnp_flussi_sistemi_interni e
|
|
where a.codice_processo=b.codice_processo
|
|
and a.codice_log=b.codice_log
|
|
and a.codice_log=c.codice_log
|
|
and a.codice_processo=d.codice_processo
|
|
and substr(a.descrizione,1,length(e.PREFISSO)) = e.PREFISSO
|
|
--and e.id_flusso in (10,11,16) elimino CU
|
|
and e.id_flusso in (10,16)
|
|
and a.data_evento between trunc(sysdate) and trunc (sysdate+1)
|
|
UNION ALL
|
|
select 'Non Definito'||'-:-'|| -- file con nome NON corretto quindi non caricati
|
|
'Non Definito'||'-:-'||
|
|
a.descrizione as attr,
|
|
b.tipo_evento as val,
|
|
c.descrizione as free,
|
|
sysdate as data_val
|
|
from mnp_evento_governance a, mnp_processo_log b, mnp_anagrafica_log c, mnp_anagrafica_processo d
|
|
where a.codice_processo=b.codice_processo
|
|
and a.codice_log=b.codice_log
|
|
and a.codice_log=c.codice_log
|
|
and a.codice_processo=d.codice_processo
|
|
and a.data_evento between trunc(sysdate) and trunc (sysdate+1)
|
|
and not exists (
|
|
select 1
|
|
from mnp_flussi_sistemi_interni e
|
|
where substr(a.descrizione,1,length(e.PREFISSO)) = e.PREFISSO
|
|
--and e.id_flusso in (10,11,16) elimino CU
|
|
and e.id_flusso in (10,16)
|
|
)
|
|
UNION ALL
|
|
select decode(e.id_flusso,
|
|
10,'Validazione CO',
|
|
11,'Validazione CO',
|
|
16,'Validazione BU')||'-:-'||
|
|
decode(e.id_flusso,
|
|
10,'CCRM',
|
|
11,'CCRM',
|
|
16,'BIT')||'-:-'||
|
|
e.prefisso as attr,
|
|
b.tipo_evento as val,
|
|
c.descrizione as free,
|
|
sysdate as data_val
|
|
from mnp_processo_log b, mnp_anagrafica_log c, mnp_anagrafica_processo d, mnp_flussi_sistemi_interni e
|
|
where b.codice_log=c.codice_log
|
|
and b.codice_processo=d.codice_processo
|
|
and b.codice_log='7308'
|
|
--and e.id_flusso in (10,11,16) elimino CU
|
|
and e.id_flusso in (10,16)
|
|
and not exists(
|
|
select 1
|
|
from mnp_evento_governance a
|
|
where substr(a.descrizione,1,length(e.PREFISSO)) = e.PREFISSO
|
|
and a.data_evento between trunc(sysdate) and trunc (sysdate+1))
|
|
)
|
|
group by attr,val,free
|
|
);
|
|
|
|
|
|
begin
|
|
dbms_output.put_line('apro il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd'));
|
|
file1 := UTL_FILE.fopen('&2','MNP' || '.' || to_char(sysdate,'yyyyMMdd'),'a');
|
|
|
|
for rec_valore in cur_valore loop
|
|
|
|
UTL_FILE.put_line(file1,'ADBCFIN01'||';'||rec_valore.attr||';'||rec_valore.val||';'||freq||';'||'&3'|| ';'
|
|
||to_char(rec_valore.data_val,'yyyymmdd')||';'||to_char(rec_valore.data_val,'hh24:mi:ss') ||';'
|
|
||to_char(sysdate,'yyyymmdd')||';'||to_char(sysdate,'hh24:mi:ss') ||';'||'0'||';'||rec_valore.attr||';'||rec_valore.free||';');
|
|
|
|
end loop;
|
|
|
|
UTL_FILE.fflush(file1);
|
|
UTL_FILE.fclose(file1);
|
|
dbms_output.put_line('chiudo il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd'));
|
|
exception
|
|
when others then
|
|
DBMS_OUTPUT.PUT_LINE(sqlerrm);
|
|
end;
|
|
/
|
|
exit |