--DEL35_DBCFX_FENP_CESS_OLO_COM8
create
or replace view del35_dbcfx_fenp_cess_olo_com8
(unique_id, id_richiesta, codice_richiesta, inbound_outbound, sistema_in_out, cod_tipo_comunicazione, desc_tipo_comunicazione, delibera, esito_notifica, data_inv_not_da_dbcfx, data_ric_not_su_dbcfx, data_notifica, codice_ordine_olo, data_ordine_olo, codice_ordine_ti, data_ordine_ti, dn, id_risorsa, nome_file_inviato_a_now, nome_file_ricevuto_da_now, cod_operatore_recipient, cod_operatore_donor, cod_operatore_donating, dac, des, dac_rimodulata, bid, unique_id_now, unique_id_crm_notify, unique_id_crm, unique_id_now_notify, data_filtro)
as
select SYS_GUID()                                       as UNIQUE_ID,
       null                                             AS ID_RICHIESTA,
       CAST(gfri.id_richiesta AS varchar2(100))         AS CODICE_RICHIESTA,
       'OUTBOUND'                                       AS INBOUND_OUTBOUND,
       CAST('FENP/NOW' AS varchar2(100))                AS SISTEMA_IN_OUT,
       gfri.tipo_comunicazione                          AS TIPO_COMUNICAZIONE,
       CAST('CESS_OLO35' AS varchar2(100))              AS DESC_TIPO_COMUNICAZIONE,
       'Del.35'                                         AS DELIBERA,
       CAST(gfri.esito_verifica_cs AS varchar2(100))    AS ESITO_NOTIFICA,
       CAST(gfri.data_invio_richiesta AS varchar2(100)) AS DATA_INV_NOT_DA_DBCFX,
       null                                             AS DATA_RIC_NOT_SU_DBCFX,
       CAST(grn.data_ricezione AS varchar2(100))        AS DATA_NOTIFICA,
       CAST(gfri.codice_ordine AS varchar2(100))        as CODICE_ORDINE_OLO,
       CAST(gfri.data_ordine AS varchar2(100))          as DATA_ORDINE_OLO,
       null                                             as CODICE_ORDINE_TI,
       null                                             as DATA_ORDINE_TI,
       CAST(gfri.dn AS varchar2(100))                   as DN,
       null                                             as ID_RISORSA,
       CAST(gfri.nome_file AS varchar2(100))            as NOME_FILE_INVIATO_A_NOW,
       null                                             as NOME_FILE_RICEVUTO_DA_NOW,
       CAST(gfri.cod_op_recipient AS varchar2(100))     AS COD_OPERATORE_RECIPIENT,
       CAST(gfri.cod_op_donor AS varchar2(100))         AS COD_OPERATORE_DONOR,
       CAST(gfri.cod_op_donating AS varchar2(100))      AS COD_OPERATORE_DONATING,
       CAST(gfri.dac AS varchar2(100))                  AS DAC,
       null                                             AS DES,
       null                                             AS DAC_RIMODULATA,
       null                                             AS BID,
       null                                             AS UNIQUE_ID_NOW,
       null                                                UNIQUE_ID_CRM_NOTIFY,
       CAST(grn.ID_RICHIESTA AS varchar2(100))             UNIQUE_ID_CRM,
       CAST(gfri.prog_id AS varchar2(100))                 UNIQUE_ID_NOW_NOTIFY,
       GRN.DATA_RICEZIONE                               as DATA_FILTRO
FROM GNP.GNP_FENP_RICHIESTE_OUT gfri
         inner join GNP_RICHIESTE_NPG35 grn on gfri.id_richiesta = grn.id_richiesta
WHERE gfri.tipo_comunicazione = 8;