First Commit - Source Code from Reply
This commit is contained in:
116
dbcmnpsrc/FE/mnpapp/script/procedure/mnp/CALCOLA_SXMLIN.prc
Normal file
116
dbcmnpsrc/FE/mnpapp/script/procedure/mnp/CALCOLA_SXMLIN.prc
Normal file
@@ -0,0 +1,116 @@
|
||||
CREATE OR REPLACE PROCEDURE calcola_sxmlin (
|
||||
nomeindicatore IN VARCHAR2,
|
||||
starthour IN NUMBER,
|
||||
endhour IN NUMBER,
|
||||
frequenza IN VARCHAR2,
|
||||
nomefile IN VARCHAR2,
|
||||
partizione IN VARCHAR2,
|
||||
hostaria IN VARCHAR2
|
||||
)
|
||||
IS
|
||||
data_val DATE;
|
||||
file1 UTL_FILE.file_type;
|
||||
|
||||
TYPE rec_valore_type IS RECORD (
|
||||
desc_olo mnp_olo.desc_olo%TYPE,
|
||||
tipo_processo_descr mnp_lov.descr%TYPE,
|
||||
tipo_file_descr mnp_lov.descr%TYPE,
|
||||
valore NUMBER
|
||||
);
|
||||
|
||||
TYPE cur_valore_type IS REF CURSOR;
|
||||
|
||||
cur_valore cur_valore_type;
|
||||
rec_valore rec_valore_type;
|
||||
sql_stmt VARCHAR2 (2000);
|
||||
BEGIN
|
||||
sql_stmt :=
|
||||
' SELECT e.desc_olo, e.tipo_processo_descr, e.tipo_file_descr,'
|
||||
|| ' COUNT (nome_file) valore'
|
||||
|| ' FROM mnp_xml_in PARTITION ('
|
||||
|| partizione
|
||||
|| ') a,'
|
||||
|| ' (SELECT b.NAME tipo_processo, b.descr tipo_processo_descr,'
|
||||
|| ' c.NAME tipo_file, c.descr tipo_file_descr, d.desc_olo'
|
||||
|| ' FROM mnp_lov b, mnp_lov c, mnp_olo d, mnp_lov_ref f'
|
||||
|| ' WHERE d.flag_terze_parti = 1'
|
||||
|| ' AND b.lov_name = ''PROCESS'''
|
||||
|| ' AND c.lov_name = ''XML_FILE_TYPE'''
|
||||
|| ' AND c.lov_id = f.lov_id'
|
||||
|| ' AND f.lov_id_ref = b.lov_id'
|
||||
|| ' AND c.NAME != ''K'') e'
|
||||
|| ' WHERE TRUNC (SYSDATE) + :starthour / 24 < a.data_eff(+)'
|
||||
|| ' AND TRUNC (SYSDATE) + :endhour / 24 >= a.data_eff(+)'
|
||||
|| ' AND e.desc_olo = a.mittente(+)'
|
||||
|| ' AND e.tipo_file = a.tipo_file(+)'
|
||||
|| ' GROUP BY e.desc_olo, e.tipo_processo_descr, e.tipo_file_descr';
|
||||
DBMS_OUTPUT.put_line ( 'apro il file '
|
||||
|| 'MNP'
|
||||
|| '.'
|
||||
|| TO_CHAR (SYSDATE, 'yyyyMMdd')
|
||||
);
|
||||
file1 :=
|
||||
UTL_FILE.fopen (nomefile,
|
||||
'MNP' || '.' || TO_CHAR (SYSDATE, 'yyyyMMdd'),
|
||||
'a'
|
||||
);
|
||||
|
||||
OPEN cur_valore
|
||||
FOR sql_stmt USING starthour, endhour;
|
||||
|
||||
data_val := SYSDATE;
|
||||
|
||||
LOOP
|
||||
FETCH cur_valore
|
||||
INTO rec_valore;
|
||||
|
||||
EXIT WHEN cur_valore%NOTFOUND; -- process record
|
||||
UTL_FILE.put_line (file1,
|
||||
nomeindicatore
|
||||
|| ';'
|
||||
|| rec_valore.desc_olo
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_processo_descr
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_file_descr
|
||||
|| ';'
|
||||
|| rec_valore.valore
|
||||
|| ';'
|
||||
|| frequenza
|
||||
|| ';'
|
||||
|| hostaria
|
||||
|| ';'
|
||||
|| TO_CHAR (data_val, 'yyyymmdd')
|
||||
|| ';'
|
||||
|| TO_CHAR (data_val, 'hh24:mi:ss')
|
||||
|| ';'
|
||||
|| TO_CHAR (SYSDATE, 'yyyymmdd')
|
||||
|| ';'
|
||||
|| TO_CHAR (SYSDATE, 'hh24:mi:ss')
|
||||
|| ';'
|
||||
|| '0'
|
||||
|| ';'
|
||||
|| rec_valore.desc_olo
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_processo_descr
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_file_descr
|
||||
|| ';;'
|
||||
);
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur_valore;
|
||||
|
||||
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;
|
||||
/
|
||||
136
dbcmnpsrc/FE/mnpapp/script/procedure/mnp/CALCOLA_SXMLOU.prc
Normal file
136
dbcmnpsrc/FE/mnpapp/script/procedure/mnp/CALCOLA_SXMLOU.prc
Normal file
@@ -0,0 +1,136 @@
|
||||
CREATE OR REPLACE PROCEDURE calcola_sxmlou (
|
||||
nomeindicatore IN VARCHAR2,
|
||||
starthour IN NUMBER,
|
||||
endhour IN NUMBER,
|
||||
frequenza IN VARCHAR2,
|
||||
nomefile IN VARCHAR2,
|
||||
partizione IN VARCHAR2,
|
||||
hostaria IN VARCHAR2
|
||||
)
|
||||
IS
|
||||
data_val DATE;
|
||||
file1 UTL_FILE.file_type;
|
||||
|
||||
TYPE rec_valore_type IS RECORD (
|
||||
desc_olo mnp_olo.desc_olo%TYPE,
|
||||
tipo_processo_descr mnp_lov.descr%TYPE,
|
||||
tipo_file_descr mnp_lov.descr%TYPE,
|
||||
valore NUMBER
|
||||
);
|
||||
|
||||
TYPE cur_valore_type IS REF CURSOR;
|
||||
|
||||
cur_valore cur_valore_type;
|
||||
rec_valore rec_valore_type;
|
||||
sql_stmt VARCHAR2 (2000);
|
||||
|
||||
BEGIN
|
||||
sql_stmt :=
|
||||
' SELECT e.desc_olo, e.tipo_processo_descr, e.tipo_file_descr,'
|
||||
|| ' COUNT (nome_file) valore'
|
||||
|| ' FROM mnp_xml_out PARTITION ('
|
||||
|| partizione
|
||||
|| ') a,'
|
||||
|| ' (SELECT b.NAME tipo_processo, b.descr tipo_processo_descr,'
|
||||
|| ' c.NAME tipo_file, c.descr tipo_file_descr, d.desc_olo'
|
||||
|| ' FROM mnp_lov b, mnp_lov c, mnp_olo d'
|
||||
|| ' WHERE (d.flag_terze_parti = 1 OR d.desc_olo = ''NPTS'')'
|
||||
|| ' AND b.lov_name = ''PROCESS'''
|
||||
|| ' AND c.lov_name = ''XML_FILE_TYPE'''
|
||||
|| ' AND ((d.flag_terze_parti = 1'
|
||||
|| ' AND (b.NAME, c.NAME) IN'
|
||||
|| ' ((''K'', ''7''),'
|
||||
|| ' (''D'', ''2''),'
|
||||
|| ' (''D'', ''5''),'
|
||||
|| ' (''D'', ''6''),'
|
||||
|| ' (''R'', ''1''),'
|
||||
|| ' (''R'', ''3''),'
|
||||
|| ' (''R'', ''9''),'
|
||||
|| ' (''P'', ''6'')) '
|
||||
|| ' ) '
|
||||
|| ' OR (d.desc_olo = ''NPTS'''
|
||||
|| ' AND (b.NAME, c.NAME) IN'
|
||||
|| ' ((''K'', ''7''),'
|
||||
|| ' (''D'', ''6''),'
|
||||
|| ' (''R'', ''3''),'
|
||||
|| ' (''R'', ''6''),'
|
||||
|| ' (''P'', ''6'')) '
|
||||
|| ' )'
|
||||
|| ' )) e '
|
||||
|| ' WHERE TRUNC (SYSDATE) + :starthour / 24 < a.data_invio(+)'
|
||||
|| ' AND TRUNC (SYSDATE) + :endhour / 24 >= a.data_invio(+)'
|
||||
|| ' AND e.desc_olo = a.destinatario(+)'
|
||||
|| ' AND e.tipo_file = a.tipo_file(+)'
|
||||
|| ' AND e.tipo_processo = a.tipo_processo(+)'
|
||||
|| ' GROUP BY e.desc_olo, e.tipo_processo_descr, e.tipo_file_descr';
|
||||
|
||||
DBMS_OUTPUT.put_line ( 'apro il file '
|
||||
|| 'MNP'
|
||||
|| '.'
|
||||
|| TO_CHAR (SYSDATE, 'yyyyMMdd')
|
||||
);
|
||||
file1 :=
|
||||
UTL_FILE.fopen (nomefile,
|
||||
'MNP' || '.' || TO_CHAR (SYSDATE, 'yyyyMMdd'),
|
||||
'a'
|
||||
);
|
||||
|
||||
OPEN cur_valore
|
||||
FOR sql_stmt USING starthour, endhour;
|
||||
|
||||
data_val := SYSDATE;
|
||||
|
||||
LOOP
|
||||
FETCH cur_valore
|
||||
INTO rec_valore;
|
||||
|
||||
EXIT WHEN cur_valore%NOTFOUND;
|
||||
UTL_FILE.put_line (file1,
|
||||
nomeindicatore
|
||||
|| ';'
|
||||
|| rec_valore.desc_olo
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_processo_descr
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_file_descr
|
||||
|| ';'
|
||||
|| rec_valore.valore
|
||||
|| ';'
|
||||
|| frequenza
|
||||
|| ';'
|
||||
|| hostaria
|
||||
|| ';'
|
||||
|| TO_CHAR (data_val, 'yyyymmdd')
|
||||
|| ';'
|
||||
|| TO_CHAR (data_val, 'hh24:mi:ss')
|
||||
|| ';'
|
||||
|| TO_CHAR (SYSDATE, 'yyyymmdd')
|
||||
|| ';'
|
||||
|| TO_CHAR (SYSDATE, 'hh24:mi:ss')
|
||||
|| ';'
|
||||
|| '0'
|
||||
|| ';'
|
||||
|| rec_valore.desc_olo
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_processo_descr
|
||||
|| '-:-'
|
||||
|| rec_valore.tipo_file_descr
|
||||
|| ';;'
|
||||
);
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur_valore;
|
||||
|
||||
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;
|
||||
/
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE OR REPLACE FUNCTION F_SPLIT_ID_OPERATORE(P_ID_OPERATORE VARCHAR2 ) RETURN VARCHAR2 IS
|
||||
V_RESULT MNP_GESTIONE_RICHIESTA_REC.ESPLETAMENTOTERZEPARTI%TYPE;
|
||||
BEGIN
|
||||
|
||||
IF INSTR(P_ID_OPERATORE, ';') > 0 OR LENGTH(TRIM(TRANSLATE(P_ID_OPERATORE, '0123456789', ' '))) IS NOT NULL THEN
|
||||
RETURN P_ID_OPERATORE;
|
||||
ELSE
|
||||
FOR i in 1 .. length(P_ID_OPERATORE) LOOP
|
||||
|
||||
V_RESULT := V_RESULT || SUBSTR(P_ID_OPERATORE,i,1)||';';
|
||||
|
||||
END LOOP;
|
||||
|
||||
RETURN(V_RESULT);
|
||||
END IF;
|
||||
|
||||
END F_SPLIT_ID_OPERATORE;
|
||||
/
|
||||
@@ -0,0 +1,9 @@
|
||||
spool compila.log
|
||||
set echo on
|
||||
|
||||
@/mnpapp/script/procedure/mnp/report_Cessazione.fnc
|
||||
show err
|
||||
|
||||
spool off
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,56 @@
|
||||
CREATE OR REPLACE PROCEDURE crea_partizione
|
||||
( p_data_partizione date default sysdate,
|
||||
p_nome_tabella varchar2,
|
||||
p_path_file_log varchar2
|
||||
) IS
|
||||
-- la procedura prende in ingresso la data di storicizzazione
|
||||
-- e imposta la data limite della nuova partizione aggiungendo 3 mesi a quella in ingresso
|
||||
|
||||
v_data_part varchar2(100);
|
||||
v_nome_part varchar2(100);
|
||||
s_partition_name_max varchar2(100);
|
||||
puntatore_file_log UTL_FILE.FILE_TYPE;
|
||||
v_anno number;
|
||||
|
||||
BEGIN
|
||||
|
||||
|
||||
v_data_part := to_char(p_data_partizione,' yyyy-mm-dd hh24:mi:ss');
|
||||
-- impostazione del nome della partizione con il seguente formato:
|
||||
-- yyyy_q anno (yyyy anno corrente - q trimestre di riferimento della partizione)
|
||||
v_nome_part := 'T'||to_char(trunc(p_data_partizione,'mm')-1,'q');
|
||||
if v_nome_part = 'T4' then
|
||||
v_anno := to_number(to_char(p_data_partizione,'yyyy'))-1;
|
||||
v_nome_part := v_nome_part||'_'||v_anno;
|
||||
else
|
||||
v_nome_part := v_nome_part||to_char(p_data_partizione, '_yyyy');
|
||||
end if;
|
||||
|
||||
puntatore_file_log := UTL_FILE.FOPEN(p_path_file_log,'crea_partizione_'||p_nome_tabella||'_'||to_char(sysdate, 'ddmmyyyy_hh24miss')||'.log','a');
|
||||
|
||||
UTL_FILE.PUT_LINE(puntatore_file_log, to_char(sysdate, 'dd/mm/yyyy hh24:mi:ss')||' Inizio Procedura crea_partizione per la tabella '||p_nome_tabella);
|
||||
|
||||
select a.partition_name
|
||||
into s_partition_name_max
|
||||
FROM all_tab_partitions a
|
||||
where a.table_name = upper(p_nome_tabella)
|
||||
and a.partition_position =
|
||||
( select max(partition_position)
|
||||
from all_tab_partitions
|
||||
where table_name = upper(p_nome_tabella));
|
||||
|
||||
execute immediate('ALTER TABLE '|| p_nome_tabella ||'
|
||||
SPLIT PARTITION ' || s_partition_name_max || ' AT (TO_DATE('''||v_data_part||''', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN''))
|
||||
INTO (PARTITION ' || v_nome_part ||',
|
||||
PARTITION ' ||s_partition_name_max||')');
|
||||
|
||||
UTL_FILE.PUT_LINE(puntatore_file_log, 'Creata partizione '||v_nome_part);
|
||||
|
||||
UTL_FILE.PUT_LINE(puntatore_file_log, to_char(sysdate, 'dd/mm/yyyy hh24:mi:ss')||' Fine Procedura crea_partizione per la tabella '||v_nome_part);
|
||||
|
||||
UTL_FILE.FCLOSE(puntatore_file_log);
|
||||
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
raise;
|
||||
END;
|
||||
/
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
CREATE OR REPLACE
|
||||
FUNCTION trova_data_part
|
||||
( data_oggi IN date)
|
||||
return varchar2 IS
|
||||
|
||||
s_data_oggi varchar2(30);
|
||||
s_data_part varchar2(30);
|
||||
|
||||
BEGIN
|
||||
for c IN 0..190 loop
|
||||
select to_char(data_oggi + c, 'ddmm') into s_data_oggi from dual;
|
||||
|
||||
if(s_data_oggi = '0104') then
|
||||
select ' '||to_char(data_oggi + c, ' yyyy-mm-dd')||' 00:00:00'
|
||||
into s_data_part
|
||||
from dual;
|
||||
|
||||
exit;
|
||||
|
||||
elsif(s_data_oggi = '0110') then
|
||||
select ' '||to_char(data_oggi + c, ' yyyy-mm-dd')||' 00:00:00'
|
||||
into s_data_part
|
||||
from dual;
|
||||
|
||||
exit;
|
||||
end if;
|
||||
|
||||
end loop;
|
||||
|
||||
RETURN s_data_part ;
|
||||
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
CREATE OR REPLACE function f_trova_ultimo_proc_concluso(
|
||||
p_msisdn varchar2,
|
||||
p_id_richiesta out varchar2,
|
||||
p_data out date,
|
||||
p_processo out varchar2,
|
||||
p_operatore_rec_rete out varchar2
|
||||
)
|
||||
return number is
|
||||
|
||||
v_result number;
|
||||
|
||||
begin
|
||||
|
||||
with t_richieste as(
|
||||
select id_richiesta, dataricezionerichiesta as data,'D' as processo, codice_operatore_recipient operatore from mnp_gestione_richiesta where msisdn= p_msisdn and stato=16
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'D' as processo, codice_operatore_recipient operatore from hist_gestione_richiesta where msisdn= p_msisdn and stato=16
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'R' as processo, codice_operatore_recipient operatore from mnp_gestione_richiesta_rec where msisdn= p_msisdn and stato=12
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'R' as processo, codice_operatore_recipient operatore from hist_gestione_richiesta_rec where msisdn= p_msisdn and stato=12
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'V' as processo, 'TIMG' operatore from mnp_gest_rich_donor_virt where msisdn= p_msisdn and stato=11
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'V' as processo, 'TIMG' operatore from hist_gest_rich_donor_virt where msisdn= p_msisdn and stato=11
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'W' as processo, 'TIMG' operatore from mnp_gest_rich_rec_virt where msisdn= p_msisdn and stato=12
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'W' as processo, 'TIMG' operatore from hist_gest_rich_rec_virt where msisdn= p_msisdn and stato=12
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'P' as processo, codice_operatore_recipient operatore from mnp_gestione_richiesta_porting where msisdn= p_msisdn and stato=6
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'P' as processo, codice_operatore_recipient operatore from hist_gestione_richiestaporting where msisdn= p_msisdn and stato=6
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'C' as processo, codice_operatore_recipient operatore from mnp_gestione_richiesta_cess where msisdn= p_msisdn and stato=3
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'K' as processo, codice_operatore_recipient operatore from mnp_gestione_rich_cess_port where msisdn= p_msisdn and stato=2
|
||||
)
|
||||
SELECT *
|
||||
into p_id_richiesta, p_data, p_processo, p_operatore_rec_rete
|
||||
from t_richieste
|
||||
WHERE DATA = (
|
||||
SELECT MAX(DATA) FROM T_RICHIESTE
|
||||
)
|
||||
and rownum < 2;
|
||||
|
||||
v_result := 0;
|
||||
|
||||
return v_result;
|
||||
|
||||
exception when others then
|
||||
|
||||
v_result := 1;
|
||||
return v_result;
|
||||
|
||||
end f_trova_ultimo_proc_concluso;
|
||||
/
|
||||
@@ -0,0 +1,56 @@
|
||||
create or replace function f_trova_ultimo_processo(
|
||||
p_msisdn varchar2,
|
||||
p_id_richiesta out varchar2,
|
||||
p_data out date,
|
||||
p_processo out varchar2
|
||||
)
|
||||
return number is
|
||||
|
||||
v_result number;
|
||||
|
||||
begin
|
||||
|
||||
with t_richieste as(
|
||||
select id_richiesta, dataricezionerichiesta as data,'D' as processo from mnp_gestione_richiesta where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'D' as processo from hist_gestione_richiesta where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'R' as processo from mnp_gestione_richiesta_rec where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'R' as processo from hist_gestione_richiesta_rec where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'V' as processo from mnp_gest_rich_donor_virt where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'V' as processo from hist_gest_rich_donor_virt where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'W' as processo from mnp_gest_rich_rec_virt where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'W' as processo from hist_gest_rich_rec_virt where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'P' as processo from mnp_gestione_richiesta_porting where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'P' as processo from hist_gestione_richiestaporting where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'C' as processo from mnp_gestione_richiesta_cess where msisdn= p_msisdn
|
||||
union
|
||||
select id_richiesta, dataricezionerichiesta as data,'K' as processo from mnp_gestione_rich_cess_port where msisdn= p_msisdn
|
||||
)
|
||||
SELECT *
|
||||
into p_id_richiesta, p_data, p_processo
|
||||
from t_richieste
|
||||
WHERE DATA = (
|
||||
SELECT MAX(DATA) FROM T_RICHIESTE
|
||||
)
|
||||
and rownum < 2;
|
||||
|
||||
v_result := 0;
|
||||
|
||||
return v_result;
|
||||
|
||||
exception when others then
|
||||
|
||||
v_result := 1;
|
||||
return v_result;
|
||||
|
||||
end f_trova_ultimo_processo;
|
||||
/
|
||||
@@ -0,0 +1,36 @@
|
||||
CREATE OR REPLACE FUNCTION report_cessazione RETURN VARCHAR2 IS
|
||||
|
||||
rs varchar2(255);
|
||||
file1 UTL_FILE.file_type;
|
||||
path varchar2(255);
|
||||
filename varchar2(255);
|
||||
|
||||
|
||||
CURSOR cur_res is
|
||||
select b.codice_richiesta_recipient || ';' || b.msisdn
|
||||
from mnp_gestione_richiesta_cess b
|
||||
where b.stato = 1
|
||||
and b.da_processare = 1
|
||||
and tim_donor =1;
|
||||
|
||||
BEGIN
|
||||
select directory_path
|
||||
into path
|
||||
from all_directories
|
||||
where directory_name='PATH_REPORT_CESS';
|
||||
filename := 'CESSAZIONI_'||to_char(sysdate,'yyyyMMddhh24miss')||'.txt';
|
||||
file1 := UTL_FILE.fopen ('PATH_REPORT_CESS',filename, 'w');
|
||||
UTL_FILE.put_line (file1,'Codice richiesta; Msisdn');
|
||||
|
||||
OPEN cur_res;
|
||||
LOOP
|
||||
FETCH cur_res INTO rs;
|
||||
EXIT WHEN cur_res%NOTFOUND;
|
||||
UTL_FILE.put_line (file1,rs);
|
||||
END LOOP;
|
||||
CLOSE cur_res;
|
||||
UTL_FILE.fflush (file1);
|
||||
UTL_FILE.fclose (file1);
|
||||
return path||'/'||filename;
|
||||
END;
|
||||
/
|
||||
Reference in New Issue
Block a user