BEGIN
   DECLARE
      V_COUNT NUMBER;
   BEGIN
      FOR C_QT IN
         (SELECT CDFILIAL, CDTABEPREC, COUNT(*) QTREGISTRO
            FROM FILITABGER
           GROUP BY CDFILIAL, CDTABEPREC
           HAVING COUNT(*) > 1) LOOP
         V_COUNT := 0;
         FOR C_DEL IN
            (SELECT CDFILIAL, CDTABEPREC, ROWID LINHA
               FROM FILITABGER
              WHERE CDFILIAL = C_QT.CDFILIAL
                AND CDTABEPREC = C_QT.CDTABEPREC) LOOP
            V_COUNT := V_COUNT + 1;
            IF V_COUNT <> C_QT.QTREGISTRO THEN
               DELETE
                 FROM FILITABGER
                WHERE ROWID = C_DEL.LINHA;
            END IF;
         END LOOP;
      END LOOP;
   END;
END;
/

ALTER TABLE FILITABGER ADD CONSTRAINT PK_FILITABGER PRIMARY KEY (CDTABEPREC, CDFILIAL)
/