CREATE OR REPLACE FUNCTION VERIF_LANCESTQ_ATUALIZADO(
   P_CDFILIAL     IN FILIAL.CDFILIAL%TYPE,
   P_NRLANCESTQ   IN LANCTOESTOQ.NRLANCESTQ%TYPE) RETURN VARCHAR2
IS
   V_ITENS NUMBER;
BEGIN
   BEGIN
   SELECT A.ITENS
     INTO V_ITENS
     FROM (SELECT COUNT(*) AS ITENS
             FROM ITLANCTOEST
            WHERE CDFILIAL   = P_CDFILIAL
              AND NRLANCESTQ = P_NRLANCESTQ) A,
          (SELECT COUNT(*) AS ITENS_ATUALIZADO
             FROM ITLANCTOEST
            WHERE CDFILIAL   = P_CDFILIAL
              AND NRLANCESTQ = P_NRLANCESTQ
              AND IDEVOLESTOQ = 'S') B
    WHERE A.ITENS = B.ITENS_ATUALIZADO;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         V_ITENS := 0;
   END;

   IF V_ITENS <> 0 THEN
      RETURN('S');
   ELSE
      RETURN('N');
   END IF;
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('VERIF_LANCESTQ_ATUALIZADO','6.39.XXX'); END;
/