CREATE OR REPLACE FUNCTION HORAS_SOLICITACAO
   (P_CDFILIAL      IN TAREFA.CDFILIAL%TYPE,
    P_NRSOLICITA    IN TAREFA.NRSOLISERV%TYPE) RETURN NUMBER
AS
   V_VRTEMPO      PLANATIVTARE.QTTEMPLAITAR%TYPE;
BEGIN
   SELECT NVL(SUM(PL.QTTEMPLAITAR),0)
     INTO V_VRTEMPO
     FROM TAREFA TF, PLANATIVTARE PL
    WHERE (TF.CDFILIAL   = P_CDFILIAL)
      AND (TF.NRSOLISERV = P_NRSOLICITA)
      AND (TF.CDFILIAL   = PL.CDFILIAL)
      AND (TF.NRTAREFA   = PL.NRTAREFA);
   RETURN(V_VRTEMPO);
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('HORAS_SOLICITACAO','5.07.008'); END;
/

