-- TABELLA TEMPORANEA PER INFASAMENTO FLUSSO DA PCCOM CREATE TABLE MNP.MNP_PCCOM_VARIAZIONI ( NUM_TEL VARCHAR2(15), DATA_ATTIVAZIONE DATE, DATA_CESSAZIONE DATE, RECIPIENT_NEW VARCHAR2(4), DATA_CESSAZIONE_DEF DATE, LAVORATO CHAR(1) ) TABLESPACE TAB_SMALL; ALTER TABLE MNP.MNP_PCCOM_VARIAZIONI add constraint PK_MNP_PCCOM_VARIAZIONI primary key (NUM_TEL) using index tablespace TAB_IDX_SMALL; -- FUNZIONE PER IL RECUPERO INFORMAZIONI FLUSSO PCCOM CREATE OR REPLACE function MNP.F_TROVA_ULTIMO_PROC_PCCOM( p_msisdn varchar2, p_id_richiesta out varchar2, p_data out date, p_data_cessazione_def 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, null, '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, null, '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, null,'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, null,'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, null,'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, null,'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, null,'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, null,'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, null,'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, null,'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, data_cut_over as data_cessazione,'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, data_cut_over as data_cessazione,'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_data_cessazione_def, 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_PCCOM; /