
ALTER TABLE MNP_GEST_RICH_REC_VIRT
 ADD (CODICE_DEALER  VARCHAR2(10))
/
 
ALTER TABLE MNP_GEST_RICH_REC_VIRT
 ADD (IDREQ_INFOBUS  VARCHAR2(24))
/
 
ALTER TABLE MNP_MSPCOOP_OUT_REC
MODIFY(ID_RICHIESTA VARCHAR2(23))
/

ALTER TABLE MNP_MSPCOOP_REC_RECUPERO_OUT
MODIFY(ID_RICHIESTA VARCHAR2(23))
/

ALTER TABLE MNP_GISP_RETRIEVE_OUT 
 ADD (
  RESP_PROFILO VARCHAR2 (3)
 )
/

-- GENERA TABELLE PER GESTIONE RECIPIENT VIRTUALE TRASFERIMENTO CREDITO--

CREATE TABLE mnp_gest_rich_rec_virt_tc
    (
    id_richiesta                   VARCHAR2(23) NOT NULL,
    stato                          NUMBER(2,0) NOT NULL,
    dataricezionerichiesta         DATE NOT NULL,
    credito                        NUMBER(7,2) NOT NULL,
    data_notifica_recipient        DATE,
    flag_verifica_credito_anomalo  NUMBER(1) DEFAULT 0,
    idreq_infobus									 VARCHAR2(24),
    version                        NUMBER
    )
    PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_gest_rich_rec_virt_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_virt_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_virt_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_virt_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_virt_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_big
 )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_rec_virt_tc
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_virt_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
CREATE INDEX idx_mnp_gest_rich_rec_virt_tc1 ON mnp_gest_rich_rec_virt_tc
(stato  ASC)
LOGGING
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_virt_tc
ADD CONSTRAINT fk_mnp_gest_rich_rec_virt_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_rec_virt (id_richiesta)
/
CREATE OR REPLACE TRIGGER pre_ins_gest_rich_rec_virt_tc
   BEFORE INSERT
   ON mnp_gest_rich_rec_virt_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_rec_virt
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
CREATE TABLE mnp_stato_rec_virt_tc
(
   id_stato   NUMBER(5)  NOT NULL ,
   descr_stato   VARCHAR2(30)  NOT NULL ,
   finale        NUMBER(1)  NOT NULL
)TABLESPACE tab_desc
/
CREATE UNIQUE INDEX pkmnp_stato_rec_virt_tc ON mnp_stato_rec_virt_tc
(id_stato  ASC)
TABLESPACE tab_desc
/
ALTER TABLE mnp_stato_rec_virt_tc
   ADD CONSTRAINT  pkmnp_stato_rec_virt_tc PRIMARY KEY (id_stato)
/
--storico
CREATE TABLE mnp_stor_rich_rec_virt_tc
    (
    id_prog                        NUMBER(18,0) NOT NULL,
    id_richiesta                   VARCHAR2(23) NOT NULL,
    note                           VARCHAR2(100),
    stato_da                       NUMBER(2,0) DEFAULT -1,
    stato_a                        NUMBER(2,0) NOT NULL, 
    credito                        NUMBER(7,2) NOT NULL, 
    data_notifica_recipient        DATE,
    data_i_o                       DATE DEFAULT SYSDATE NOT NULL,
    data_lavorazione               DATE DEFAULT TRUNC(SYSDATE),
    dataricezionerichiesta         DATE NOT NULL
   )
      PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_stor_rich_rec_virt_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_virt_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_virt_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_virt_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_virt_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_huge
  )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_stor_rich_rec_virt_tc
(id_prog)
TABLESPACE tab_idx_huge_2_1
/
ALTER TABLE mnp_stor_rich_rec_virt_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_prog)
    USING INDEX
    TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_rec_virt_tc1 ON mnp_stor_rich_rec_virt_tc
(id_richiesta  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_rec_virt_tc2 ON mnp_stor_rich_rec_virt_tc
(data_lavorazione  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE OR REPLACE TRIGGER pre_ins_stor_rich_rec_virt_tc
   BEFORE INSERT
   ON mnp_stor_rich_rec_virt_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_rec_virt_tc
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
ALTER TABLE mnp_stor_rich_rec_virt_tc
ADD CONSTRAINT fk_mnp_stor_rich_rec_virt_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_rec_virt_tc (id_richiesta)
/
CREATE SEQUENCE seq_rich_rec_virt_storico_tc
/
-- FINE TABELLE PER STORICO RECIPIENT VIRTUALE TRASFERIMENTO CREDITO--

-- GENERA TABELLE PER GESTIONE DONOR VIRTUALE TRASFERIMENTO CREDITO--

CREATE TABLE mnp_gest_rich_don_virt_tc
    (
    id_richiesta                   VARCHAR2(23) NOT NULL,
    stato                          NUMBER(2,0) NOT NULL,
    dataricezionerichiesta         DATE NOT NULL,
    credito                        NUMBER(7,2) NOT NULL,
    data_notifica_recipient        DATE,
    idreq_infobus									 VARCHAR2(24),
    version                        NUMBER
    )
   PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_gest_rich_don_virt_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_virt_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_virt_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_virt_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_virt_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_big
 )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_don_virt_tc
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_virt_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
CREATE INDEX idx_mnp_gest_rich_don_virt_tc1 ON mnp_gest_rich_don_virt_tc
(stato  ASC)
LOGGING
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_virt_tc
ADD CONSTRAINT fk_mnp_gest_rich_don_virt_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES MNP_GEST_RICH_DONOR_VIRT (id_richiesta)
/
CREATE OR REPLACE TRIGGER pre_ins_gest_rich_don_virt_tc
   BEFORE INSERT
   ON mnp_gest_rich_don_virt_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_donor_virt
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
CREATE TABLE mnp_stato_don_virt_tc
(
   id_stato   NUMBER(5)  NOT NULL ,
   descr_stato   VARCHAR2(30)  NOT NULL ,
   finale        NUMBER(1)  NOT NULL
)TABLESPACE tab_desc
/
CREATE UNIQUE INDEX pkmnp_stato_don_virt_tc ON mnp_stato_don_virt_tc
(id_stato  ASC)
TABLESPACE tab_desc
/
ALTER TABLE mnp_stato_don_virt_tc
   ADD CONSTRAINT  pkmnp_stato_don_virt_tc PRIMARY KEY (id_stato)
/
-- FINE TABELLE PER GESTIONE DONOR VIRTUALE TRASFERIMENTO CREDITO--

-- GENERA TABELLE PER STORICO DONOR VIRTUALE TRASFERIMENTO CREDITO--
CREATE TABLE mnp_stor_rich_don_virt_tc
    (
    id_prog                        NUMBER(18,0) NOT NULL,
    id_richiesta                   VARCHAR2(23) NOT NULL,
    note                            VARCHAR2(100),
    stato_da                       NUMBER(2,0) DEFAULT -1,
    stato_a                        NUMBER(2,0) NOT NULL, 
    credito                        NUMBER(7,2) NOT NULL, --riferito a stato_da
    data_notifica_recipient        DATE, --riferito a stato_da
    data_i_o                       DATE DEFAULT SYSDATE                NOT NULL,
    data_lavorazione               DATE DEFAULT TRUNC(SYSDATE),
    dataricezionerichiesta         DATE NOT NULL
    )
    PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_stor_rich_don_virt_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_virt_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_virt_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_virt_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_virt_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_huge
  )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_stor_rich_don_virt_tc
(id_prog)
TABLESPACE tab_idx_huge_2_1
/
ALTER TABLE mnp_stor_rich_don_virt_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_prog)
    USING INDEX
    TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_don_virt_tc1 ON mnp_stor_rich_don_virt_tc
(id_richiesta  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_don_virt_tc2 ON mnp_stor_rich_don_virt_tc
(data_lavorazione  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE OR REPLACE TRIGGER pre_ins_stor_rich_don_virt_tc
   BEFORE INSERT
   ON mnp_stor_rich_don_virt_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_don_virt_tc
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
ALTER TABLE mnp_stor_rich_don_virt_tc
ADD CONSTRAINT fk_mnp_stor_rich_don_virt_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_don_virt_tc (id_richiesta)
/
CREATE SEQUENCE seq_rich_don_virt_storico_tc
/
-- FINE TABELLE PER STORICO DONOR VIRTUALE TRASFERIMENTO CREDITO--

-- GENERA TABELLE PER GESTIONE RECIPIENT TRASFERIMENTO CREDITO--

CREATE TABLE mnp_gest_rich_rec_tc
    (
    id_richiesta                   VARCHAR2(23) NOT NULL,
    stato                          NUMBER(2,0) NOT NULL,
    dataricezionerichiesta         DATE NOT NULL,
    credito                        NUMBER(7,2) NOT NULL,
    data_notifica_recipient        DATE,
    flag_verifica_credito_anomalo  NUMBER(1) DEFAULT 0,
    version                        NUMBER
    )
    PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_gest_rich_rec_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_rec_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_big
 )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_rec_tc
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
CREATE INDEX idx_mnp_gest_rich_rec_tc1 ON mnp_gest_rich_rec_tc
(stato  ASC)
LOGGING
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_tc
ADD CONSTRAINT fk_mnp_gest_rich_rec_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gestione_richiesta_rec (id_richiesta)
/
CREATE OR REPLACE TRIGGER pre_ins_gest_rich_rec_tc
   BEFORE INSERT
   ON mnp_gest_rich_rec_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gestione_richiesta_rec
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
CREATE TABLE mnp_stato_rec_tc
(
   id_stato   NUMBER(5)  NOT NULL ,
   descr_stato   VARCHAR2(30)  NOT NULL ,
   finale        NUMBER(1)  NOT NULL
)TABLESPACE tab_desc;

CREATE UNIQUE INDEX pkmnp_stato_rec_tc ON mnp_stato_rec_tc
(id_stato  ASC)
TABLESPACE tab_desc;

ALTER TABLE mnp_stato_rec_tc
   ADD CONSTRAINT  pkmnp_stato_rec_tc PRIMARY KEY (id_stato)
/
--storico
CREATE TABLE mnp_stor_rich_rec_tc
    (
    id_prog                        NUMBER(18,0) NOT NULL,
    id_richiesta                   VARCHAR2(23) NOT NULL,
    note                            VARCHAR2(100),
    stato_da                       NUMBER(2,0) DEFAULT -1,
    stato_a                        NUMBER(2,0) NOT NULL, 
    credito                        NUMBER(7,2) NOT NULL, 
    data_notifica_recipient        DATE, 
    data_i_o                       DATE DEFAULT SYSDATE NOT NULL,
    data_lavorazione               DATE DEFAULT TRUNC(SYSDATE),
    dataricezionerichiesta         DATE NOT NULL
   )
      PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_stor_rich_rec_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_rec_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_huge
  )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_stor_rich_rec_tc
(id_prog)
TABLESPACE tab_idx_huge_2_1
/
ALTER TABLE mnp_stor_rich_rec_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_prog)
    USING INDEX
    TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_rec_tc1 ON mnp_stor_rich_rec_tc
(id_richiesta  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_rec_tc2 ON mnp_stor_rich_rec_tc
(data_lavorazione  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE OR REPLACE TRIGGER pre_ins_storico_rich_rec_tc
   BEFORE INSERT
   ON mnp_stor_rich_rec_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_rec_tc
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
ALTER TABLE mnp_stor_rich_rec_tc
ADD CONSTRAINT fk_mnp_stor_rich_rec_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_rec_tc (id_richiesta)
/
CREATE SEQUENCE seq_rich_rec_storico_tc
/
-- FINE TABELLE PER STORICO RECIPIENT TRASFERIMENTO CREDITO--

-- GENERA TABELLE PER GESTIONE DONOR TRASFERIMENTO CREDITO--

CREATE TABLE mnp_gest_rich_don_tc
    (
    id_richiesta                   VARCHAR2(23) NOT NULL,
    stato                          NUMBER(2) NOT NULL,
    dataricezionerichiesta         DATE NOT NULL,
    credito                        NUMBER(7,2) NOT NULL,
    data_notifica_recipient        DATE,
    flag_verifica_credito_anomalo  NUMBER(1) DEFAULT 0,
    da_inviare                     NUMBER(1) NOT NULL,
    idreq_infobus									 VARCHAR2(24),
    version                        NUMBER
    )
   PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_gest_rich_don_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_big,
  PARTITION mnp_gest_rich_don_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_big
 )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_don_tc
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
CREATE INDEX idx_mnp_gest_rich_don_tc1 ON mnp_gest_rich_don_tc
(stato  ASC)
LOGGING
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_tc
ADD CONSTRAINT fk_mnp_gest_rich_don_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES MNP_GESTIONE_RICHIESTA (id_richiesta)
/
CREATE OR REPLACE TRIGGER pre_ins_gest_rich_don_tc
   BEFORE INSERT
   ON mnp_gest_rich_don_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gestione_richiesta
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
CREATE TABLE mnp_stato_don_tc
(
   id_stato   NUMBER(5)  NOT NULL ,
   descr_stato   VARCHAR2(30)  NOT NULL ,
   finale        NUMBER(1)  NOT NULL
)TABLESPACE tab_desc;

CREATE UNIQUE INDEX pkmnp_stato_don_tc ON mnp_stato_don_tc
(id_stato  ASC)
TABLESPACE tab_desc
/
ALTER TABLE mnp_stato_don_tc
   ADD CONSTRAINT  pkmnp_stato_don PRIMARY KEY (id_stato)
/
-- FINE TABELLE PER GESTIONE DONOR TRASFERIMENTO CREDITO--

-- GENERA TABELLE PER STORICO DONOR TRASFERIMENTO CREDITO--
CREATE TABLE mnp_stor_rich_don_tc
    (
    id_prog                        NUMBER(18,0) NOT NULL,
    id_richiesta                   VARCHAR2(23) NOT NULL,
    note                            VARCHAR2(100),
    stato_da                       NUMBER(2,0) DEFAULT -1,
    stato_a                        NUMBER(2,0) NOT NULL, 
    credito                        NUMBER(7,2) NOT NULL, --riferito a stato_da
    data_notifica_recipient        DATE, --riferito a stato_da
    data_i_o                       DATE DEFAULT SYSDATE                NOT NULL,
    data_lavorazione               DATE DEFAULT TRUNC(SYSDATE),
    dataricezionerichiesta         DATE NOT NULL
    )
      PARTITION BY RANGE (dataricezionerichiesta)
  (
  PARTITION mnp_stor_rich_don_tc1 VALUES LESS THAN (TO_DATE('20090401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_tc2 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_tc3 VALUES LESS THAN (TO_DATE('20100401','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_tc4 VALUES LESS THAN (TO_DATE('20101001','YYYYMMDD'))
   NOLOGGING
   TABLESPACE tab_huge,
  PARTITION mnp_stor_rich_don_tc5_max VALUES LESS THAN (MAXVALUE)
   NOLOGGING
   TABLESPACE tab_huge
  )
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_stor_rich_don_tc
(id_prog)
TABLESPACE tab_idx_huge_2_1
/
ALTER TABLE mnp_stor_rich_don_tc ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_prog)
    USING INDEX
    TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_don_tc1 ON mnp_stor_rich_don_tc
(id_richiesta  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE INDEX idx_mnp_stor_rich_don_tc2 ON mnp_stor_rich_don_tc
(data_lavorazione  ASC)
LOGGING
TABLESPACE tab_idx_huge_2_1
/
CREATE OR REPLACE TRIGGER pre_ins_storico_rich_don_tc
   BEFORE INSERT
   ON mnp_stor_rich_don_tc
   FOR EACH ROW
BEGIN
   SELECT dataricezionerichiesta
     INTO :NEW.dataricezionerichiesta
     FROM mnp_gest_rich_don_tc
    WHERE id_richiesta = :NEW.id_richiesta;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      :NEW.dataricezionerichiesta := SYSDATE;
END;
/
ALTER TABLE mnp_stor_rich_don_tc
ADD CONSTRAINT fk_mnp_stor_rich_don_tc_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_don_tc (id_richiesta)
/
CREATE SEQUENCE seq_rich_don_storico_tc
/
-- FINE TABELLE PER STORICO DONOR TRASFERIMENTO CREDITO--

-- MODIFICHE TABELLE DI BUSINESS MNP
alter table MNP_GESTIONE_RICHIESTA
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL,
    FLAG_ESP                    NUMBER(1,0) DEFAULT 0 NOT NULL,
    CODICE_OPERATORE_DON_EFF    VARCHAR2(4),
    CODICE_OPERATORE_REC_EFF    VARCHAR2(4)
)
/
alter table MNP_GESTIONE_RICHIESTA_REC
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL,
    FLAG_ESP                    NUMBER(1,0) DEFAULT 0 NOT NULL,
    CODICE_OPERATORE_DON_EFF    VARCHAR2(4),
    CODICE_OPERATORE_REC_EFF    VARCHAR2(4),
    ID_CONTRATTO                VARCHAR2(18)
)
/
alter table MNP_GESTIONE_RICHIESTA_PORTING
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL,
    CODICE_OPERATORE_DON_EFF    VARCHAR2(4),
    CODICE_OPERATORE_REC_EFF    VARCHAR2(4)
)
/
alter table MNP_GEST_RICH_DONOR_VIRT
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL, 
    FLAG_ESP                    NUMBER(1,0) DEFAULT 0 NOT NULL,
    ID_CONTRATTO                VARCHAR2(18)
)
/
alter table MNP_GEST_RICH_REC_VIRT
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL, 
    FLAG_ESP                    NUMBER(1,0) DEFAULT 0 NOT NULL
)
/
alter table MNP_RICHIESTA_DUP
ADD (
    FLAG_TC                     VARCHAR2(1) DEFAULT 'N' NOT NULL, 
    CODICE_OPERATORE_DON_EFF    VARCHAR2(4),
    CODICE_OPERATORE_REC_EFF    VARCHAR2(4)
)
/

-- FINE MODIFICA TAB. BUSINESS

-- TABELLA DI INTEGRAZIONE AOM SISTEMI INTERNI

CREATE TABLE MNP_ANAGRAFICA_OPERATORI
(
   ID_OPERATORE     VARCHAR2(4)  NOT NULL,
   TIPO_OPERATORE   VARCHAR2(10)  NOT NULL,
   GESTORE_AOM      VARCHAR2(4)  NOT NULL,
   ID_AMMINISTRATIVO VARCHAR2(4)  NULL,
   INIZIALE_ID_AMM  VARCHAR2(1)  NULL,
   DESCRIZIONE      VARCHAR2(50) NOT NULL
)TABLESPACE tab_desc
/
CREATE UNIQUE INDEX pkmnp_anagrafica_operatori ON MNP_ANAGRAFICA_OPERATORI
(ID_OPERATORE  ASC)
TABLESPACE tab_desc
/
ALTER TABLE MNP_ANAGRAFICA_OPERATORI
   ADD CONSTRAINT  pkmnp_anagrafica_operatori PRIMARY KEY (ID_OPERATORE)
/

DROP TABLE MNP_OPERATORE_GISP CASCADE CONSTRAINTS
/
CREATE TABLE MNP_OPERATORE_GISP
(
    ID_OPERATORE_GISP  NUMBER  NOT NULL ,
    ID_ANAG_OPERATORI VARCHAR2(4) NOT NULL ,
    NOME_OPERATORE      VARCHAR2(20)  NOT NULL 
)
TABLESPACE TAB_DESC
/

CREATE UNIQUE INDEX PK_MNP_OPERATORE_GISP ON MNP_OPERATORE_GISP
(ID_OPERATORE_GISP  ASC)
TABLESPACE TAB_DESC
/

ALTER TABLE MNP_OPERATORE_GISP
    ADD CONSTRAINT  PK_MNP_OPERATORE_GISP PRIMARY KEY (ID_OPERATORE_GISP)
/

-- FINE GENERAZIONE TABELLA OPERATORE GISP --


-- INIZIO ESTENSIONE TABELLE CCRM_NOTIFICA_OUT --


ALTER TABLE MNP_CCRM_NOTIFICA_OUT 
add (
		FLAG_TC VARCHAR2(1) DEFAULT 'N' NOT NULL,
		CREDITO VARCHAR2(8)
)
/		

ALTER TABLE MNP_CCRMW_COOP_NOT_OUT 
add (
	FLAG_TC VARCHAR2(1) DEFAULT 'N' NOT NULL,
	CREDITO VARCHAR2(8)
)
/


-- FINE ESTENSIONE TABELLE CCRM_NOTIFICA_OUT --


-- Inizio generazione tabelle per notifica trasferimento credito MVNO --

CREATE TABLE mnp_mvno_tc_in (
    unique_id                      NUMBER NOT NULL,
    idreq_infobus                  VARCHAR2(24) NOT NULL,
    data_ricezione                 DATE DEFAULT SYSDATE NOT NULL,
    da_scodare                     NUMBER(1) NOT NULL,
    evento_dbc                     NUMBER(2) NOT NULL,
    tipo_evento                    VARCHAR2(2) NOT NULL,
    id_richiesta_dbc               VARCHAR2(23) NOT NULL,
    IMPORTO_CREDITO_RESIDUO        VARCHAR2(8) NOT NULL,
    FLAG_VERIFICA_CREDITO_ANOMALO  VARCHAR2(1),
    business_id                    VARCHAR2(36) NOT NULL)
TABLESPACE  tab_big
/
ALTER TABLE mnp_mvno_tc_in
ADD CONSTRAINT pk_mnp_mvno_tc_in PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_big
/
CREATE TABLE mnp_mvno_scarto_tc_in (
    unique_id                      NUMBER NOT NULL,
    data_ricezione                 DATE DEFAULT SYSDATE NOT NULL,
    record_scartato                VARCHAR2(4000),
    causale_scarto                 VARCHAR2(255),
    idreq_infobus                  VARCHAR2(24)
)
TABLESPACE  tab_medium
/
ALTER TABLE mnp_mvno_scarto_tc_in
ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_medium
/
-- Fine generazione tabelle per notifica trasferimento credito MVNO --
--Modifica tabella notifica donor out per i campi di trasferimento credito--

ALTER TABLE MNP_MVNO_NOTIFICA_DON_OUT 
ADD    (
        FLAG_TC VARCHAR2(1) DEFAULT 'N',
        DATA_NOTIFICA_CREDITO VARCHAR2(8),
        ORA_NOTIFICA_CREDITO VARCHAR2(5)
)
/
--Modifica tabella porting in recipient MVNO

ALTER TABLE MNP_MVNO_PORTING_IN
 ADD (FLAG_TC  VARCHAR2(1) DEFAULT 'N' NOT NULL)
/
--Modifica tabella notifiche recipient MVNO 

ALTER TABLE MNP_MVNO_NOTIFICA_REC_OUT 
ADD    (
        DATA_NOTIFICA_CREDITO  VARCHAR2(8),
        ORA_NOTIFICA_CREDITO  VARCHAR2(5),
        IMPORTO_CREDITO_RESIDUO  VARCHAR2(8),
        FLAG_VERIFICA_CREDITO_ANOMALO  VARCHAR2(1)
)
/


-- INIZIO GESTIONE MSP E MSPCOOP

alter table MNP_MSPCOOP_IN_REC ADD (
    FLAG_TC  VARCHAR2(1) DEFAULT 'N' NOT NULL
)
/
alter table MNP_MSPCOOP_SCARTI_IN ADD (
    FLAG_TC  VARCHAR2(1) NULL
)
/
alter table MNP_MSP_IN_REC ADD (
    FLAG_TC  VARCHAR2(1) DEFAULT 'N' NOT NULL
)
/
alter table MNP_MSP_SCARTI_IN ADD (
    FLAG_TC  VARCHAR2(1) NULL
)
/
-- FINE GESTIONE MSP

-- INIZIO GESTIONE MSP E MSPCOOP OUT
alter table MNP_MSP_OUT_REC 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N',
    CODICE_DONATING VARCHAR2(4) NULL,
    CREDITO VARCHAR2(8) NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NULL
)
/

alter table MNP_MSPCOOP_OUT_REC 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N',
    CODICE_DONATING VARCHAR2(4) NULL,
    CREDITO VARCHAR2(8) NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NULL
)
/

alter table MNP_MSP_RECIPIENT_RECUPERO_OUT 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N',
    CODICE_DONATING VARCHAR2(4) NULL,
    CREDITO VARCHAR2(8) NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NULL
)
/

alter table MNP_MSPCOOP_REC_RECUPERO_OUT 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N',
    CODICE_DONATING VARCHAR2(4) NULL,
    CREDITO VARCHAR2(8) NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NULL
)
/
-- FINE GESTIONE MSP E MSPCOOP OUT

-- INIZIO GESTIONE CCRM-CCRMCOOP RECUPERO OUT
alter table MNP_CCRM_RECUPERO_OUT 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N' NOT NULL,
    CREDITO VARCHAR2(8) NULL
)
/
alter table MNP_CCRMW_COOP_RECUPERO_OUT 
ADD (
    FLAG_TC VARCHAR2(1) DEFAULT 'N' NOT NULL,
    CREDITO VARCHAR2(8) NULL
)
/

-- FINE GESTIONE CCRM-CCRMCOOP RECUPERO OUT


-- INIZIO (MSP-MSPCOOP) NOTIFICA_FINE_TRASFERIMENTO_CREDITO 

CREATE TABLE MNP_MSP_END_TC_OUT(
    UNIQUE_ID NUMBER NOT NULL, 
    DATA_CREAZIONE DATE DEFAULT SYSDATE NOT NULL,
    DATA_INVIO DATE NULL,
    DA_SCODARE NUMBER(1) NOT NULL,
    ID_RICHIESTA VARCHAR2(23) NOT NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NOT NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NOT NULL,
    MSISDN VARCHAR2(12) NOT NULL,
    IDREQ_INFOBUS VARCHAR2(24) NOT NULL
) TABLESPACE TAB_MEDIUM
/
CREATE UNIQUE INDEX PK_MNP_MSP_END_TC_OUT ON MNP_MSP_END_TC_OUT(UNIQUE_ID) TABLESPACE TAB_IDX_MEDIUM
/
ALTER TABLE MNP_MSP_END_TC_OUT ADD (CONSTRAINT PK_MNP_MSP_END_TC_OUT PRIMARY KEY(UNIQUE_ID))
/


CREATE TABLE MNP_MSPCOOP_END_TC_OUT(
    UNIQUE_ID NUMBER NOT NULL, 
    DATA_CREAZIONE DATE DEFAULT SYSDATE NOT NULL,
    DATA_INVIO DATE NULL,
    DA_SCODARE NUMBER(1) NOT NULL,
    ID_RICHIESTA VARCHAR2(23) NOT NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NOT NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NOT NULL,
    MSISDN VARCHAR2(12) NOT NULL,
    IMPORTO_CREDITO_RESIDUO VARCHAR2(8) NOT NULL,
    IDREQ_INFOBUS VARCHAR2(24) NOT NULL
) TABLESPACE TAB_MEDIUM
/
CREATE UNIQUE INDEX PK_MNP_MSPCOOP_END_TC_OUT ON MNP_MSPCOOP_END_TC_OUT(UNIQUE_ID) TABLESPACE TAB_IDX_MEDIUM
/
ALTER TABLE MNP_MSPCOOP_END_TC_OUT ADD (CONSTRAINT PK_MNP_MSPCOOP_END_TC_OUT PRIMARY KEY(UNIQUE_ID))
/
-- FINE (MSP) NOTIFICA_FINE_TRASFERIMENTO_CREDITO 
--INIIZIO (MSP) ACQUISIZIONE EVENTO NOTIFICA TRASFERIMENTO CREDITO
CREATE SEQUENCE SEQ_MSP
/
CREATE TABLE MNP_MSP_TC_IN (
    UNIQUE_ID                      NUMBER NOT NULL,
    IDREQ_INFOBUS                  VARCHAR2(24) NOT NULL,
    DATA_RICEZIONE                 DATE DEFAULT SYSDATE NOT NULL,
    DA_SCODARE                     NUMBER(1) NOT NULL,
    EVENTO_DBC                     NUMBER(2) NOT NULL,
    TIPO_EVENTO                    VARCHAR2(2) NOT NULL,
    ID_RICHIESTA_DBC               VARCHAR2(23) NOT NULL,
    IMPORTO_CREDITO_RESIDUO        VARCHAR2(8) NOT NULL
) TABLESPACE  tab_big
/
ALTER TABLE mnp_msp_tc_in
ADD CONSTRAINT pk_mnp_msp_tc_in PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_big
/

CREATE TABLE mnp_msp_scarto_tc_in (
    unique_id                      NUMBER NOT NULL,
    data_ricezione                 DATE DEFAULT SYSDATE NOT NULL,
    record_scartato                VARCHAR2(4000),
    causale_scarto                 VARCHAR2(255),
    idreq_infobus                  VARCHAR2(24)
)
TABLESPACE  tab_medium
/
ALTER TABLE mnp_msp_scarto_tc_in
ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_medium
/

CREATE SEQUENCE seq_msp_end_tc_out
/

CREATE SEQUENCE seq_mspcoop_end_tc_out
/
--FINE (MSP) NOTIFICA TRASFERIMENTO CREDITO

--INIIZIO (MSP-ESP) ACQUISIZIONE EVENTO NOTIFICA TRASFERIMENTO CREDITO
CREATE SEQUENCE SEQ_MSPCOOP
/
CREATE TABLE MNP_MSPCOOP_TC_IN  (
    UNIQUE_ID                      NUMBER NOT NULL,
    IDREQ_INFOBUS                  VARCHAR2(24) NOT NULL,
    DATA_RICEZIONE                 DATE DEFAULT SYSDATE NOT NULL,
    DA_SCODARE                     NUMBER(1) NOT NULL,
    EVENTO_DBC                     NUMBER(2) NOT NULL,
    TIPO_EVENTO                    VARCHAR2(2) NOT NULL,
    ID_RICHIESTA_DBC               VARCHAR2(23) NOT NULL,
    IMPORTO_CREDITO_RESIDUO        VARCHAR2(8) NOT NULL)
TABLESPACE  tab_big
/
ALTER TABLE MNP_MSPCOOP_TC_IN
ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_big
/

CREATE TABLE mnp_mspcoop_scarto_tc_in (
    unique_id                      NUMBER NOT NULL,
    data_ricezione                 DATE DEFAULT SYSDATE NOT NULL,
    record_scartato                VARCHAR2(4000),
    causale_scarto                 VARCHAR2(255),
    idreq_infobus                  VARCHAR2(24)
)
TABLESPACE  tab_medium
/
ALTER TABLE mnp_mspcoop_scarto_tc_in
ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id)
USING INDEX
TABLESPACE  tab_idx_medium
/
--FINE (MSP) NOTIFICA TRASFERIMENTO CREDITO


-- INIZIO GESTIONE MSC

ALTER TABLE MNP_MSC_IN_REC 
 ADD (
  FLAG_TC VARCHAR2(1) DEFAULT 'N' NOT NULL,
  ID_CONTRATTO VARCHAR2(18)
 );
 
ALTER TABLE MNP_MSC_SCARTI_IN 
 ADD (
  FLAG_TC VARCHAR2(1),
  ID_CONTRATTO VARCHAR2(18)
 );
 
ALTER TABLE MNP_MSC_OUT_REC ADD (
	CODICE_DONATING VARCHAR2(4),
	FLAG_TC VARCHAR2(1) DEFAULT 'N',
	CREDITO VARCHAR2(8),
	ID_CONTRATTO VARCHAR2(18)
);

ALTER TABLE MNP_MSC_RECIPIENT_RECUPERO_OUT ADD (
	CODICE_DONATING VARCHAR2(4),
	FLAG_TC VARCHAR2(1) DEFAULT 'N',
	CREDITO VARCHAR2(8),
	ID_CONTRATTO VARCHAR2(18)
);
-- FINE GESTIONE MSC

-- INIZIO GESTION BIT IN

ALTER TABLE MNP_BIT_IN_REC 
 ADD (
  FLAG_TC VARCHAR2 (1) DEFAULT 'N' NOT NULL
 );
 
 ALTER TABLE MNP_BIT_SCARTI_IN 
 ADD (
  FLAG_TC VARCHAR2 (1)
 );

-- FINE GESTIONE BIT IN
-- CESSAZIONI
ALTER TABLE MNP_ASP_CRM_CESSAZIONE_OUT
 ADD (FLAG_TC  VARCHAR2(1));

-- FINE CESSAZIONI


-- INIZIO GESTIONE MNP_BIT_TC_DONOR_OUT
CREATE TABLE MNP_BIT_TC_DONOR_OUT (
    UNIQUE_ID NUMBER NOT NULL,
    DATA_CREAZIONE DATE DEFAULT SYSDATE NOT NULL,
    DATA_INVIO DATE NULL,
    DA_SCODARE NUMBER(1) NOT NULL,
    EVENTO_DBC NUMBER(2) NOT NULL,
    ID_RICHIESTA VARCHAR2(64) NOT NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NOT NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NOT NULL,
    CREDITO VARCHAR2(8) NOT NULL,
    CODICE_EVENTO VARCHAR2(2) NOT NULL
) TABLESPACE tab_medium
/
CREATE UNIQUE INDEX PK_MNP_BIT_TC_DONOR_OUT ON MNP_BIT_TC_DONOR_OUT(UNIQUE_ID) TABLESPACE TAB_IDX_MEDIUM
/
ALTER TABLE MNP_BIT_TC_DONOR_OUT ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id) USING INDEX TABLESPACE  tab_idx_medium
/
CREATE SEQUENCE seq_bit_tc_donor_out
/
-- FINE GESTIONE MNP_BIT_TC_DONOR_OUT 


-- INIZIO GESTION MNP_BIT_PPBU_OUT_REC

CREATE TABLE MNP_BIT_PPBU_OUT_REC (
    UNIQUE_ID NUMBER NOT NULL,
    DATA_CREAZIONE DATE DEFAULT SYSDATE NOT NULL,
    DATA_INVIO DATE NULL,
    DA_SCODARE NUMBER(1) NOT NULL,
    EVENTO_DBC NUMBER(2) NOT NULL,
    TIPO_SPEDIZIONE VARCHAR2(2) NOT NULL,
    ID_RICHIESTA_DBC VARCHAR2(23) NOT NULL,
    MSISDN VARCHAR2(13) NOT NULL,
    CODFISCALE_PIVA VARCHAR2(16) NOT NULL,
    CODICE_PROFILO_TARIFFARIO VARCHAR2(10) NULL,
    DESC_PROFILO_TARIFFARIO VARCHAR2(50) NULL,
    STATO_RICHIESTA VARCHAR2(30) NOT NULL,
    CAUSALE_RIFIUTO VARCHAR2(50) NULL,
    DATA_ORA_EFFETTIVA_VALIDAZIONE VARCHAR2(19) NULL,
    DATA_CUT_OVER VARCHAR2(10) NOT NULL,
    FLAG_RIACCREDITO VARCHAR2(1) NOT NULL,
    CODICE_DONATING VARCHAR2(4) NOT NULL,
    CREDITO VARCHAR2(8) NULL,
    DATA_NOTIFICA_CREDITO VARCHAR2(8) NULL,
    ORA_NOTIFICA_CREDITO VARCHAR2(5) NULL
) TABLESPACE tab_huge
/
CREATE UNIQUE INDEX PK_MNP_BIT_PPBU_OUT_REC ON MNP_BIT_PPBU_OUT_REC(UNIQUE_ID) TABLESPACE TAB_IDX_huge_2_1
/
ALTER TABLE MNP_BIT_PPBU_OUT_REC ADD CONSTRAINT [REDACTED]PRIMARY KEY (unique_id) USING INDEX TABLESPACE TAB_IDX_huge_2_1
/
CREATE SEQUENCE seq_bit_ppbu_out_rec
/

-- FINE GESTIONE MNP_BIT_PPBU_OUT_REC

-- INIZIO GESTION BIT OUT
ALTER TABLE MNP_BIT_OUT_REC
ADD (
    TIPO_SPEDIZIONE             VARCHAR2(2) DEFAULT '07' NOT NULL,
    CREDITO                     VARCHAR2(8) ,
    DATA_NOTIFICA_CREDITO       VARCHAR2(8) ,
    ORA_NOTIFICA_CREDITO        VARCHAR2(5)
);

ALTER TABLE MNP_BIT_RECIPIENT_RECUPERO_OUT
ADD (
    TIPO_SPEDIZIONE             VARCHAR2(2) DEFAULT '07' NOT NULL,
    CREDITO                     VARCHAR2(8) ,
    DATA_NOTIFICA_CREDITO       VARCHAR2(8) ,
    ORA_NOTIFICA_CREDITO        VARCHAR2(5)
);
-- FINE GESTIONE BIT OUT

ALTER TABLE MNP_CRM_VALIDAZIONE_OUT
ADD (
    CODICE_OPERATORE_RECIPIENT             VARCHAR2(4) ,
    FLAG_RIACCREDITO                       VARCHAR2(1) DEFAULT 'N' NOT NULL
);

ALTER TABLE MNP_BIT_ANNULL_OUT
ADD (
    CODICE_OPERATORE_RECIPIENT             VARCHAR2(4) ,
    FLAG_RIACCREDITO                       VARCHAR2(1) DEFAULT 'N' NOT NULL
);


-- SINCRONIZZAZIONE DBC-DBCGO
ALTER TABLE MNP_DBCGO_NOTIFICA_DONOR_OUT ADD (
	FLAG_TC 			VARCHAR2(1) NULL,	
	DATA_PRESA_IN_CARICO		DATE NULL,
	CODICE_OPERATORE_DON_EFF	VARCHAR2(4) NULL,
	CODICE_OPERATORE_REC_EFF	VARCHAR2(4) NULL
)
/
ALTER TABLE MNP_DBCGO_NOTIFICA_REC_OUT ADD (
	FLAG_TC 			VARCHAR2(1) NULL,	
	DATA_PRESA_IN_CARICO		DATE NULL,
	CODICE_OPERATORE_DON_EFF	VARCHAR2(4) NULL,
	CODICE_OPERATORE_REC_EFF	VARCHAR2(4) NULL
)
/
ALTER TABLE MNP_DBCGO_NOTIFICA_PORTING_OUT ADD (
	CODICE_OPERATORE_DON_EFF	VARCHAR2(4) NULL,
	CODICE_OPERATORE_REC_EFF	VARCHAR2(4) NULL
)
/
CREATE TABLE MNP_DBCGO_NOTIFICA_DON_TC_OUT (
	UNIQUE_ID		VARCHAR2(50)	NOT NULL,
	DA_SCODARE		NUMBER(1)	DEFAULT 0,
	DATA_CREAZIONE		DATE NOT NULL,
	DATA_INVIO		DATE		NULL,
	DATA_TRANSIZIONE	DATE		NULL,
  	ID_RICHIESTA            VARCHAR2(23)    NOT NULL,
  	STATO                   NUMBER(2)       NOT NULL,
  	CREDITO                 VARCHAR2(8)     NOT NULL,
  	DATA_NOTIFICA_CREDITO   DATE        	NULL,
  	NOME_FILE_XML_TC        VARCHAR2(27)    NULL
) TABLESPACE TAB_BIG
/
ALTER TABLE MNP_DBCGO_NOTIFICA_DON_TC_OUT ADD CONSTRAINT [REDACTED]PRIMARY KEY (UNIQUE_ID) USING INDEX TABLESPACE TAB_IDX_BIG
/
CREATE INDEX idx_dbcgo_notifica_don_tc_out ON MNP_DBCGO_NOTIFICA_DON_TC_OUT(ID_RICHIESTA) LOGGING TABLESPACE TAB_IDX_BIG
/

CREATE TABLE MNP_DBCGO_NOTIFICA_REC_TC_OUT (
	UNIQUE_ID		VARCHAR2(50)	NOT NULL,
	DA_SCODARE		NUMBER(1)	DEFAULT 0,
	DATA_CREAZIONE		DATE NOT NULL,
	DATA_INVIO		DATE		NULL,
	DATA_TRANSIZIONE	DATE		NULL,  
  	ID_RICHIESTA            VARCHAR2(23)    NOT NULL,
  	STATO                   NUMBER(2)       NOT NULL,
  	CREDITO                 VARCHAR2(8)     NOT NULL,
  	DATA_NOTIFICA_CREDITO   DATE        	NULL,
  	NOME_FILE_XML_TC        VARCHAR2(27)    NULL
) TABLESPACE TAB_BIG
/
ALTER TABLE MNP_DBCGO_NOTIFICA_REC_TC_OUT ADD CONSTRAINT [REDACTED]PRIMARY KEY (UNIQUE_ID) USING INDEX TABLESPACE TAB_IDX_BIG
/
CREATE INDEX idx_dbcgo_notifica_rec_tc_out ON MNP_DBCGO_NOTIFICA_REC_TC_OUT(ID_RICHIESTA) LOGGING TABLESPACE TAB_IDX_BIG
/
CREATE SEQUENCE seq_notifica_don_tc_out
/
CREATE SEQUENCE seq_notifica_rec_tc_out
/
ALTER TABLE MNP_GESTIONE_RICHIESTA_EXT 
 ADD (
  DATA_PRESA_IN_CARICO DATE
 )
/
ALTER TABLE MNP_GESTIONE_RICHIESTA_REC_EXT 
 ADD (
  DATA_PRESA_IN_CARICO DATE
 )
/
CREATE TABLE mnp_gest_rich_don_tc_ext (
		ID_RICHIESTA            VARCHAR2(23) NOT NULL,
		NOME_FILE_XML_TC        VARCHAR2(27)    NULL
)TABLESPACE tab_big
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_don_tc_ext
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_tc_ext ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_don_tc_ext
ADD CONSTRAINT fk_mnp_gest_rich_don_tc_ext_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_don_tc (id_richiesta)
/
CREATE TABLE mnp_gest_rich_rec_tc_ext (
		ID_RICHIESTA            VARCHAR2(23) NOT NULL,
		NOME_FILE_XML_TC        VARCHAR2(27)    NULL
)TABLESPACE tab_big
/
CREATE UNIQUE INDEX [REDACTED]ON mnp_gest_rich_rec_tc_ext
(id_richiesta)
TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_tc_ext ADD
  CONSTRAINT [REDACTED] PRIMARY KEY
 (id_richiesta)
    USING INDEX
    TABLESPACE tab_idx_big
/
ALTER TABLE mnp_gest_rich_rec_tc_ext
ADD CONSTRAINT fk_mnp_gest_rich_rec_tc_ext_1 FOREIGN KEY (id_richiesta)
REFERENCES mnp_gest_rich_rec_tc (id_richiesta)
/



