--TABELLA MNP_FENP_XML_IN
CREATE TABLE MNP_FENP_XML_IN
(
  PROG_ID         NUMBER                        NOT NULL,
  NOME_FILE       VARCHAR2(50 BYTE)             NOT NULL,
  DATA_RICEZIONE  DATE                          DEFAULT SYSDATE,
  TIPO_FILE       VARCHAR2(1 BYTE)              NOT NULL,
  XML             CLOB                          NOT NULL,
  DA_SCODARE      NUMBER(1)                     DEFAULT 0
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
LOB (XML) STORE AS 
      ( TABLESPACE  USR 
        ENABLE      STORAGE IN ROW
        CHUNK       8192
        RETENTION
        NOCACHE
        INDEX       (
          TABLESPACE USR
          STORAGE    (
                      INITIAL          10M
                      NEXT             1
                      MINEXTENTS       1
                      MAXEXTENTS       UNLIMITED
                      PCTINCREASE      0
                      FREELISTS        1
                      FREELIST GROUPS  1
                      BUFFER_POOL      DEFAULT
                     ))
        STORAGE    (
                    INITIAL          64M
                    NEXT             10M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    PCTINCREASE      0
                    FREELISTS        1
                    FREELIST GROUPS  1
                    BUFFER_POOL      DEFAULT
                   )
      )
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX IDX_MNP_FENP_XML_IN_1 ON MNP_FENP_XML_IN
(NOME_FILE)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_IN ON MNP_FENP_XML_IN
(PROG_ID)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_IN ADD (
  CONSTRAINT PK_MNP_FENP_XML_IN
 PRIMARY KEY
 (PROG_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ),
  CONSTRAINT IDX_MNP_FENP_XML_IN_1
 UNIQUE (NOME_FILE)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_OUT               
CREATE TABLE MNP_FENP_XML_OUT
(
  UNIQUE_ID       NUMBER                        NOT NULL,
  DA_INVIARE      NUMBER(1)                     DEFAULT '0'                   NOT NULL,
  DATA_CREAZIONE  DATE                          DEFAULT SYSDATE,
  DATA_INVIO      DATE,
  NOME_FILE       VARCHAR2(50 BYTE)             NOT NULL,
  TIPO_FILE       VARCHAR2(1 BYTE)              NOT NULL,
  IDFILE          VARCHAR2(5 BYTE)              NOT NULL,
  XML             CLOB                          NOT NULL
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
LOB (XML) STORE AS 
      ( TABLESPACE  USR 
        ENABLE      STORAGE IN ROW
        CHUNK       8192
        RETENTION
        NOCACHE
        INDEX       (
          TABLESPACE USR
          STORAGE    (
                      INITIAL          10M
                      NEXT             1
                      MINEXTENTS       1
                      MAXEXTENTS       UNLIMITED
                      PCTINCREASE      0
                      FREELISTS        1
                      FREELIST GROUPS  1
                      BUFFER_POOL      DEFAULT
                     ))
        STORAGE    (
                    INITIAL          64M
                    NEXT             10M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    PCTINCREASE      0
                    FREELISTS        1
                    FREELIST GROUPS  1
                    BUFFER_POOL      DEFAULT
                   )
      )
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_OUT ON MNP_FENP_XML_OUT
(UNIQUE_ID)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_OUT ADD (
  CONSTRAINT PK_MNP_FENP_XML_OUT
 PRIMARY KEY
 (UNIQUE_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_ACK_OUT
CREATE TABLE MNP_FENP_XML_ACK_OUT
(
  NOME_FILE       VARCHAR2(50 BYTE)             NOT NULL,
  XML             VARCHAR2(1000 BYTE)           NOT NULL,
  DATA_RICEZIONE  DATE                          DEFAULT SYSDATE,
  CODE            CHAR(2 BYTE)                  NOT NULL,
  DESCR           VARCHAR2(50 BYTE)             NOT NULL,
  EXT_DESCR       VARCHAR2 (255 BYTE)
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_ACK_OUT ON MNP_FENP_XML_ACK_OUT
(NOME_FILE)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_ACK_OUT ADD (
  CONSTRAINT PK_MNP_FENP_XML_ACK_OUT
 PRIMARY KEY
 (NOME_FILE)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_ACK_IN
CREATE TABLE MNP_FENP_XML_ACK_IN
(
  PROG_ID         NUMBER                        NOT NULL,
  PROG_ID_SCARTI  NUMBER,
  NOME_FILE       VARCHAR2(50 BYTE),
  DATA_CREAZIONE  DATE                          DEFAULT SYSDATE,
  XML             VARCHAR2(500 BYTE)            NOT NULL,
  CODE            CHAR(2 BYTE)                  NOT NULL,
  DESCR           VARCHAR2(50 BYTE)             NOT NULL,
  EXT_DESCR       VARCHAR2(255 BYTE)
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE INDEX IDX_MNP_FENP_XML_ACK_IN_1 ON MNP_FENP_XML_ACK_IN
(NOME_FILE)
LOGGING
TABLESPACE USR
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_ACK_IN ON MNP_FENP_XML_ACK_IN
(PROG_ID)
LOGGING
TABLESPACE USR
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_ACK_IN ADD (
  CONSTRAINT PK_MNP_FENP_XML_ACK_IN
 PRIMARY KEY
 (PROG_ID)
    USING INDEX 
    TABLESPACE USR
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_RICHIESTE_OUT
CREATE TABLE MNP_FENP_XML_RICHIESTE_OUT
(
  PROG_ID               NUMBER                        NOT NULL,
  NOME_FILE             VARCHAR2(50 BYTE),
  DATA_CREAZIONE        DATE                          DEFAULT SYSDATE,
  TIPO_COMUNICAZIONE    VARCHAR2(2 BYTE)              NOT NULL,
  DA_PROCESSARE         NUMBER(1)                     NOT NULL,
  ID_RICHIESTA          VARCHAR2(18 BYTE)             NOT NULL,
  DATA_ORDINE           DATE                                  NOT NULL,
  RIENTRO_TI                 NUMBER(1)                     NOT NULL,
  DN                    VARCHAR2(12 BYTE)             NOT NULL,
  OPERATORE_DONATING     VARCHAR2(3 BYTE)                DEFAULT 'TIM',
  OPERATORE_RECIPIENT     VARCHAR2(3 BYTE)              DEFAULT 'KEA',
  DATA_INVIO_RICHIESTA  DATE,
  NOMINATIVO_CLIENTE VARCHAR2(120 BYTE)
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_RICHIESTE_OUT ON MNP_FENP_XML_RICHIESTE_OUT
(PROG_ID)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_RICHIESTE_OUT ADD (
  CONSTRAINT PK_MNP_FENP_XML_RICHIESTE_OUT
 PRIMARY KEY
 (PROG_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_RICHIESTE_IN
CREATE TABLE MNP_FENP_XML_RICHIESTE_IN
(
  PROG_ID               NUMBER                        NOT NULL,
  NOME_FILE             VARCHAR2(50 BYTE)             NOT NULL,
  DATA_RICEZIONE        DATE                          DEFAULT SYSDATE NOT NULL,
  TIPO_COMUNICAZIONE    VARCHAR2(2 BYTE)              NOT NULL,
  DA_SCODARE            NUMBER(1)                     NOT NULL,
  ID_RICHIESTA          VARCHAR2(18 BYTE),
  DATA_ORDINE           DATE				                  NOT NULL,
  DN                    VARCHAR2(12 BYTE)             NOT NULL,
  DAC				DATE			NOT NULL,
  CLIENTE			VARCHAR2(60 BYTE) NOT NULL,
  CODICE_SEGRETO		VARCHAR2(3 BYTE),
  TELEFONO_RICHIEDENTE	VARCHAR2(12 BYTE) NOT NULL,
  E_MAIL_RICHIEDENTE	VARCHAR2(60 BYTE) NOT NULL,
  ESITO                	NUMBER(1),
  CODICE_MOTIVO_RIFIUTO   NUMBER(2),
  DESCRIZIONE_RIFIUTO  	VARCHAR2(255),
  DATA_INVIO_MESSAGGIO	DATE,
  DATA_ESPLETAMENTO_ORD	DATE,
  OPERATORE_DONATING	VARCHAR2(3 BYTE),
  OPERATORE_DONOR		VARCHAR2(3 BYTE)	NOT NULL	
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_RICHIESTE_IN ON MNP_FENP_XML_RICHIESTE_IN
(PROG_ID)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_RICHIESTE_IN ADD (
  CONSTRAINT PK_MNP_FENP_XML_RICHIESTE_IN
 PRIMARY KEY
 (PROG_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--TABELLA MNP_FENP_XML_SCARTI_IN
CREATE TABLE MNP_FENP_XML_SCARTI_IN
(
    PROG_ID         NUMBER NOT NULL,
  DATA_RICEZIONE    DATE DEFAULT SYSDATE,
  NOME_FILE         VARCHAR2(50 BYTE),
  XML               CLOB
)
TABLESPACE USR
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
LOB (XML) STORE AS 
      ( TABLESPACE  USR 
        ENABLE      STORAGE IN ROW
        CHUNK       8192
        RETENTION
        NOCACHE
        INDEX       (
          TABLESPACE USR
          STORAGE    (
                      INITIAL          10M
                      NEXT             1
                      MINEXTENTS       1
                      MAXEXTENTS       UNLIMITED
                      PCTINCREASE      0
                      FREELISTS        1
                      FREELIST GROUPS  1
                      BUFFER_POOL      DEFAULT
                     ))
        STORAGE    (
                    INITIAL          64M
                    NEXT             10M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    PCTINCREASE      0
                    FREELISTS        1
                    FREELIST GROUPS  1
                    BUFFER_POOL      DEFAULT
                   )
      )
NOCACHE
NOPARALLEL
NOMONITORING;
CREATE UNIQUE INDEX PK_MNP_FENP_XML_SCARTI_IN ON MNP_FENP_XML_SCARTI_IN
(PROG_ID)
LOGGING
TABLESPACE TAB_IDX_BIG
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          32M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_FENP_XML_SCARTI_IN ADD (
  CONSTRAINT PK_MNP_FENP_XML_SCARTI_IN
 PRIMARY KEY
 (PROG_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          32M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
--Creazione sequence
CREATE SEQUENCE SEQ_FENP increment by 1 start with 1;

