CREATE OR REPLACE TRIGGER DTCADAFORN_FORN
BEFORE INSERT ON FORNECEDOR FOR EACH ROW
BEGIN
    IF INSERTING THEN
        :NEW.DTCADAFORN := SYSDATE;
    END IF;
END;
/

DECLARE
    V_COUNT NUMBER := 0;
BEGIN
    FOR C_FORNECEDOR IN (SELECT ROWID, FORNECEDOR.DTINCLUSAO, FORNECEDOR.DTULTATUFORN
                           FROM FORNECEDOR
                          WHERE DTCADAFORN IS NULL)
    LOOP
        UPDATE FORNECEDOR
           SET DTCADAFORN = NVL(NVL(C_FORNECEDOR.DTINCLUSAO, C_FORNECEDOR.DTULTATUFORN), SYSDATE)
         WHERE ROWID = C_FORNECEDOR.ROWID;
        IF V_COUNT > 500 THEN
            V_COUNT :=  0;
            COMMIT;
        END IF;
        V_COUNT := V_COUNT + 1;
    END LOOP;
    COMMIT;
END;
/