CREATE OR REPLACE FUNCTION FERIADO_BANCARIO(
   P_CDFILIAL IN FILIAL.CDFILIAL%TYPE,
   P_DTATUAL  IN DATE) RETURN DATE IS

   V_DTBASE   DATE;
   V_COUNT    INTEGER;
BEGIN
   V_COUNT  := 1;
   V_DTBASE := P_DTATUAL;

   WHILE (V_COUNT > 0) LOOP
      SELECT COUNT(*)
        INTO V_COUNT
        FROM FERIBANC
       WHERE CDFILIAL = P_CDFILIAL
         AND DTFERIBANC = V_DTBASE;

      IF V_COUNT > 0 THEN
         V_DTBASE := V_DTBASE + V_COUNT;
      END IF;
   END LOOP;
   RETURN (V_DTBASE);
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('FERIADO_BANCARIO','5.50.xxx'); END;
/