ALTER TABLE FCT_ITEMCONTRATO ADD NRESTRUTURAM NUMBER
/

CREATE INDEX SM00363_FK ON FCT_ITEMCONTRATO(NRESTRUTURAM ASC)
/


ALTER TABLE FCT_ITEMCONTRATO ADD CONSTRAINT FKSM00363ITEMCONT_ESTRUTURAM
    FOREIGN KEY (NRESTRUTURAM) REFERENCES ESTRUTURAM (NRESTRUTURAM)
/

DELETE FROM FCT_CALCFORMPRECSERV_ITCONT
 WHERE NRITEMOCONTRATO IS NULL
    OR NRITEMOCONTRATO NOT IN (SELECT NRITEMOCONTRATO
                                 FROM FCT_ITEMCONTRATO)
/

CREATE INDEX SM00364_FK ON FCT_CALCFORMPRECSERV_ITCONT(NRITEMOCONTRATO ASC)
/


ALTER TABLE FCT_CALCFORMPRECSERV_ITCONT ADD CONSTRAINT FKSM00364CALCFORMPREC_ITCONT
    FOREIGN KEY (NRITEMOCONTRATO) REFERENCES FCT_ITEMCONTRATO (NRITEMOCONTRATO) ON DELETE CASCADE
/