CREATE OR REPLACE FUNCTION STATUS_ITEMPEDIDO(
   P_CDFILIAL IN PEDIDO.CDFILIAL%TYPE,
   P_NRPEDIDO IN PEDIDO.NRPEDIDO%TYPE,
   P_STATUSITEM IN VARCHAR2) RETURN VARCHAR2 IS

   V_COUNT   INTEGER;
   V_RESULT  VARCHAR2(01);
BEGIN
   V_RESULT := 'N';
   V_COUNT := 0;
   SELECT COUNT(1)
     INTO V_COUNT
     FROM ITEMPEDIDO I
    WHERE I.CDFILIAL = P_CDFILIAL
      AND I.NRPEDIDO = P_NRPEDIDO
      AND (INSTR(P_STATUSITEM , I.IDSITITEMPED) > 0);

   IF V_COUNT > 0 THEN
      V_RESULT := 'S';
   END IF;
   RETURN(V_RESULT);
END;
/
-- VERSAO --
BEGIN ATUVEROBJ('STATUS_ITEMPEDIDO','6.25.xxx'); END;
/
