ALTER TABLE DETITMAPARECUP ADD IDTPSUBAPURCP VARCHAR2(5) NULL 
/

ALTER TABLE ITMAPARECUP ADD IDINDSUBAPURCP VARCHAR2(5) NULL
/ 

ALTER TABLE ITMAPARECUP ADD DSOUTRASUBAPUR VARCHAR2(250) NULL
/

ALTER TABLE INSCRESTAD ADD IDTPMERCSUBAPURCP VARCHAR2(1) NULL 
/

ALTER TABLE INSCRESTAD ADD DSAJDEVOLESTIMPO  VARCHAR2(250) NULL
/

ALTER TABLE INSCRESTAD ADD CDAJDEVOLESTIMPO  VARCHAR2(20)
/

ALTER TABLE INSCRESTAD ADD DSAJESTDEVOLIMPO  VARCHAR2(250) NULL
/

ALTER TABLE INSCRESTAD ADD CDAJUSTEDEVOLIMPO  VARCHAR2(20)
/

ALTER TABLE INSCRESTAD ADD IDESTAPURCREDIMPO  VARCHAR2(5) NULL
/

ALTER TABLE INSCRESTAD ADD DSESTORNOCPIMPO    VARCHAR2(250) NULL
/

ALTER TABLE INSCRESTAD ADD CDAJESTORCPIMPO  VARCHAR2(20)
/

ALTER TABLE INSCRESTAD ADD DSOUTAPURCPIMPO   VARCHAR2(250) NULL
/

ALTER TABLE INSCRESTAD ADD IDINDSUBAPURIMP   VARCHAR2(5) NULL
/

ALTER TABLE INSCRESTAD ADD IDSUBAPURPRODIMP  VARCHAR2(5) NULL  
/

ALTER TABLE CREDPRESPRODUTO ADD IDPRODIMPORTADO VARCHAR2(5) NULL
/ 

BEGIN
   FOR C_CURSOR IN (SELECT E.IDINDICSUBAPURCP, M.NRSEQUMAPAPU 
                      FROM ITMAPARECUP IT, INSCRESTAD E, MAPAAPURAC M
                     WHERE IT.IDESTSUBAPUR = 'S'
                       AND IT.NRSEQUMAPAPU = M.NRSEQUMAPAPU
                       AND E.CDINSCESTA    = M.CDINSCESTA
                       AND E.IDINDICSUBAPURCP IS NOT NULL
                       AND IT.IDINDSUBAPURCP  IS NULL) LOOP

      UPDATE ITMAPARECUP 
         SET IDINDSUBAPURCP = C_CURSOR.IDINDICSUBAPURCP
       WHERE NRSEQUMAPAPU  = C_CURSOR.NRSEQUMAPAPU
         AND IDESTSUBAPUR = 'S';    
   END LOOP;
END;
/ 

COMMIT
/