CREATE OR REPLACE TRIGGER EXCLUI_RESERVAPEDEXOL
AFTER UPDATE OF IDBAIXAOLSAI, IDITEMAJUSTE
ON ITEMPEDEXOL FOR EACH ROW
BEGIN
   IF UPDATING THEN
      IF ((NVL(:NEW.IDBAIXAOLSAI, '0') = '1') OR (NVL(:NEW.IDBAIXAOLSAI, '0') = '2') OR
         (NVL(:NEW.IDBAIXAOLSAI, '0') = '3')  OR (NVL(:NEW.IDITEMAJUSTE, 'N') = 'S')) THEN
         DELETE FROM RESERVAPEDEXOL
          WHERE CDFILDEST     = :OLD.CDFILDEST
            AND CDFILLANC     = :OLD.CDFILLANC
            AND NRPEDEXOL     = :OLD.NRPEDEXOL
            AND CDPRODUTO     = :OLD.CDPRODUTO
            AND CDMARCA       = :OLD.CDMARCA
            AND DTPROGENPEOL  = :OLD.DTPROGENPEOL;
      END IF;
   END IF;
END;
/
-- VERSAO --
BEGIN ATUVEROBJ('EXCLUI_RESERVAPEDEXOL','5.30.XXX'); END;
/
