CREATE OR REPLACE TRIGGER DTULTATU_GRUPOPER
BEFORE INSERT OR UPDATE OR DELETE
ON GRUPOPER FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATUGROP := SYSDATE;
   END IF;
   IF UPDATING THEN
      IF (NVL(:OLD.CDGRUPOPER,0) <> NVL(:NEW.CDGRUPOPER,0)) OR
         (NVL(:OLD.DSGRUPOPER,0) <> NVL(:NEW.DSGRUPOPER,0)) OR
         (NVL(:OLD.IDUTCTRSENOP,0) <> NVL(:NEW.IDUTCTRSENOP,0)) OR
         (NVL(:OLD.DSSENHACAIXA,0) <> NVL(:NEW.DSSENHACAIXA,0)) OR
         (NVL(:OLD.IDALTERCORES,0) <> NVL(:NEW.IDALTERCORES,0)) OR
         (NVL(:OLD.IDALTERIDIOMAS,0) <> NVL(:NEW.IDALTERIDIOMAS,0)) OR
         (NVL(:OLD.IDALTERCONFIG,0) <> NVL(:NEW.IDALTERCONFIG,0)) OR
         (NVL(:OLD.IDEMITIRFECHA,0) <> NVL(:NEW.IDEMITIRFECHA,0)) OR
         (NVL(:OLD.IDCANCELARVENDAS,0) <> NVL(:NEW.IDCANCELARVENDAS,0)) OR
         (NVL(:OLD.IDBLOCKPROD,0) <> NVL(:NEW.IDBLOCKPROD,0)) OR
         (NVL(:OLD.IDALTERMODAL,0) <> NVL(:NEW.IDALTERMODAL,0)) OR
         (NVL(:OLD.IDALTERIMP,0) <> NVL(:NEW.IDALTERIMP,0)) OR
         (NVL(:OLD.IDALTERLAYOUT,0) <> NVL(:NEW.IDALTERLAYOUT,0)) OR
         (NVL(:OLD.IDALTERCONFIGGERAIS,0) <> NVL(:NEW.IDALTERCONFIGGERAIS,0)) OR
         (NVL(:OLD.IDALTERIMAGENS,0) <> NVL(:NEW.IDALTERIMAGENS,0)) OR
         (NVL(:OLD.IDIMPORTARCONFIG,0) <> NVL(:NEW.IDIMPORTARCONFIG,0)) OR
         (NVL(:OLD.IDEXPORTARCONFIG,0) <> NVL(:NEW.IDEXPORTARCONFIG,0)) OR
         (NVL(:OLD.IDPARAMETROS,0) <> NVL(:NEW.IDPARAMETROS,0)) OR
         (NVL(:OLD.IDGESTAOSISTEM,0) <> NVL(:NEW.IDGESTAOSISTEM,0)) OR
         (NVL(:OLD.IDCONFIGVERSAO,0) <> NVL(:NEW.IDCONFIGVERSAO,0)) OR
         (NVL(:OLD.IDGERENSERVI,0) <> NVL(:NEW.IDGERENSERVI,0)) THEN
         :NEW.DTULTATUGROP := SYSDATE;
      END IF;
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('GRUPOPER', '', 'CDGRUPOPER='||:OLD.CDGRUPOPER||';', SYSDATE);
   END IF;
END;
/

