CREATE OR REPLACE TRIGGER ATUALIZA_PROJETO
BEFORE UPDATE ON PROJETO FOR EACH ROW

BEGIN
   IF (:NEW.IDSITPROJETO = 'A') AND (:OLD.IDTIPOPROJETO = '2') THEN

      FOR C_TAREFA IN (SELECT TA.CDFILIAL, TA.NRTAREFA
                       FROM
                          SOLISERV SO, SOLIBASELINE SL, TAREFA TA
                       WHERE SL.CDFILIAL   = SO.CDFILIAL
                         AND SL.NRSOLISERV = SO.NRSOLISERV
                         AND SL.CDFILIAL   = :NEW.CDFILIAL
                         AND SL.CDPROJETO = :NEW.CDPROJETO
                         AND SL.CDFILIAL   = TA.CDFILIAL
                         AND SO.NRSOLISERV = TA.NRSOLISERV
                         AND TA.IDORIGTARE = '5') LOOP
         UPDATE TAREFA
         SET IDORIGTARE = '1'
         WHERE CDFILIAL = C_TAREFA.CDFILIAL
           AND NRTAREFA = C_TAREFA.NRTAREFA;

      END LOOP;
   END IF;
END;
/
-- VERSAO --
BEGIN ATUVEROBJ('ATUALIZA_PROJETO','5.05.011'); END;
/

