create or replace FUNCTION DIAUTIL(
   P_CDFILIAL     IN FILIAL.CDFILIAL%TYPE,
   P_DTBASE       IN PEDIDO.DTPEDIDO%TYPE) RETURN BOOLEAN IS

   V_COUNT INTEGER;
   V_DTFINAL   DATE;
   BODIAUTIL   BOOLEAN;
BEGIN
   V_COUNT := 0;
   SELECT COUNT(1)
     INTO V_COUNT
     FROM FERIFILI
    WHERE CDFILIAL = P_CDFILIAL
      AND TO_CHAR(DTFERIFILI, 'DD/MM/YYYY') = TO_CHAR(P_DTBASE, 'DD/MM/YYYY');
   IF V_COUNT = 0 THEN
      RETURN(TRUE);
   ELSE
      RETURN(FALSE);
   END IF;
END;
/