CREATE OR REPLACE TRIGGER DTULTATU_CONFIGVOO
BEFORE INSERT OR UPDATE OR DELETE
ON CONFIGVOO FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATUCFVO := SYSDATE;
   END IF;
   IF UPDATING THEN
      IF (NVL(:OLD.QTPAXVOO,0) <> NVL(:NEW.QTPAXVOO,0)) OR
         (NVL(:OLD.CDAGRDEL,0) <> NVL(:NEW.CDAGRDEL,0)) OR
         (NVL(:OLD.QTPAXSBYVOO  ,0) <> NVL(:NEW.QTPAXSBYVOO  ,0)) THEN
         :NEW.DTULTATUCFVO := SYSDATE;
      END IF;
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('CONFIGVOO',:OLD.CDFILIAL, 'CDFILIAL='||:OLD.CDFILIAL||';CDCIA='||:OLD.CDCIA||';NRVOO='||:OLD.NRVOO||';CDTRECHO='||:OLD.CDTRECHO||';CDCLASSE='||:OLD.CDCLASSE||';', SYSDATE);
   END IF;
END;
/

ALTER TABLE CONFIGVOO MODIFY DTULTATUCFVO DEFAULT SYSDATE
/