---DA ESEGUIRE COME UTENTE DWH

ALTER TABLE mnp_report_agcom RENAME COLUMN csv TO csv_old;
ALTER TABLE mnp_report_agcom ADD csv CLOB;

UPDATE mnp_report_agcom a
   SET csv = (SELECT csv_old
                FROM mnp_report_agcom b
               WHERE a.anno = b.anno AND a.mese = b.mese AND a.tipo = b.tipo);
COMMIT ;

ALTER TABLE mnp_report_agcom DROP COLUMN csv_old;
-------------------------------------------------------------------------------
CREATE OR REPLACE VIEW MNP_REPORT_AGCOM_VIEW
(
  ANNO, MESE,TIPO, DATA_CREAZIONE, CSV1,CSV2,CSV3
)
AS
(SELECT ANNO, MESE,TIPO, DATA_CREAZIONE, to_char(SUBSTR(CSV,1,4000)),
 to_char(SUBSTR(CSV,4001,8000)),to_char(SUBSTR(CSV,8001,12000))
FROM MNP_REPORT_AGCOM);