CREATE OR REPLACE TRIGGER DTUTLATU_PAR_GERAL_FAS
BEFORE INSERT OR UPDATE OR DELETE
ON PAR_GERAL_FAS FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATUPFAS := SYSDATE;
   END IF;
   IF UPDATING THEN
      IF (NVL(:OLD.CDPROFATLUSO, 0) <> NVL(:NEW.CDPROFATLUSO,0))OR
         (NVL(:OLD.CDPROFATMANU, 0) <> NVL(:NEW.CDPROFATMANU,0))OR
         (NVL(:OLD.CDPROFATLOCA, 0) <> NVL(:NEW.CDPROFATLOCA,0))OR
         (NVL(:OLD.VRPECOMILUSO, 0) <> NVL(:NEW.VRPECOMILUSO,0))OR
         (NVL(:OLD.VRPECOMIMANU, 0) <> NVL(:NEW.VRPECOMIMANU,0))OR
         (NVL(:OLD.VRPECOMILOCA, 0) <> NVL(:NEW.VRPECOMILOCA,0))OR
         (NVL(:OLD.CDPRODFATSOLI, 0) <> NVL(:NEW.CDPRODFATSOLI,0))OR
         (NVL(:OLD.CDPROFATSOLI, 0) <> NVL(:NEW.CDPROFATSOLI,0)) THEN
          :NEW.DTULTATUPFAS := SYSDATE;
      END IF;
   END IF;

   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('PAR_GERAL_FAS', '', 'PARGERALFAS='||:OLD.CDPROFATLUSO||';', SYSDATE);
   END IF;
END;
/
 
ALTER TABLE PAR_GERAL_FAS MODIFY DTULTATUPFAS DEFAULT SYSDATE
/


-- VERSAO --
BEGIN ATUVEROBJ('DTUTLATU_PAR_GERAL_FAS','4.11.167'); END;
/

