ALTER TABLE CONTAPAGAR ADD CDRATEIO VARCHAR2(03) NULL
/

ALTER TABLE CONTAPAGAR
   	ADD CONSTRAINT FKFIN00417PADRATEIO FOREIGN KEY (CDRATEIO)
      		REFERENCES PADRATEIO (CDRATEIO)
/
CREATE INDEX FIN00417_FK ON CONTAPAGAR (CDRATEIO)
/

DELETE FROM ITEMRATEIO
WHERE CDRATEIO IN (
SELECT CDRATEIO FROM (
SELECT SUM(ROUND(VRRATEIO,2)), CDRATEIO FROM ITEMRATEIO
GROUP BY CDRATEIO
HAVING SUM(ROUND(VRRATEIO,2)) <> 100))
/
COMMIT
/