create or replace FUNCTION CONSULTA_LEITURA_QRCODE(P_CDFILIAL  IN LOTEQRCODE.CDFILIAL%TYPE,
                                                 P_NRPEDIDO  IN LOTEQRCODE.NRPEDIDO%TYPE,
                                                 P_NRITEMPED IN LOTEQRCODE.NRITEMPED%TYPE)RETURN VARCHAR2
AS
V_EXISTS FLOAT;
V_RET VARCHAR2(1);
BEGIN
   BEGIN 
      SELECT COUNT(1)
        INTO V_EXISTS
        FROM LOTEQRCODE
       WHERE CDFILIAL = P_CDFILIAL
         AND NRPEDIDO = P_NRPEDIDO  
         AND NRITEMPED = P_NRITEMPED;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN BEGIN
         V_EXISTS := 0;
      END;
   END; 
   
   IF V_EXISTS = '1' THEN 
      V_RET := 'S';
   ELSE
      V_RET := 'N';
   END IF;

   RETURN(V_RET);

END;
/

