CREATE OR REPLACE TRIGGER DTULTATU_EMPR
BEFORE INSERT OR UPDATE OR DELETE
ON EMPRESA FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATUEMPR := SYSDATE;
   END IF;
   IF UPDATING THEN    
      :NEW.DTULTATUEMPR := SYSDATE;      
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('EMPRESA', '', 'CDEMPRESA='||:OLD.CDEMPRESA||';', SYSDATE);
   END IF;
END;
/

ALTER TABLE EMPRESA MODIFY DTULTATUEMPR DEFAULT SYSDATE
/

UPDATE EMPRESA SET DTULTATUEMPR = SYSDATE WHERE DTULTATUEMPR IS NULL
/