CREATE OR REPLACE TRIGGER DTULTATU_PROCESGPROC
BEFORE INSERT OR UPDATE OR DELETE
ON PROCESGPROC FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATUPROGPRO := SYSDATE;
   END IF;
   IF UPDATING THEN
      IF (NVL(:OLD.CDGRUPROCESSO,0) <> NVL(:NEW.CDGRUPROCESSO,0)) OR
         (NVL(:OLD.CDPROCESSO,0) <> NVL(:NEW.CDPROCESSO,0)) THEN
         :NEW.DTULTATUPROGPRO := SYSDATE;
      END IF;
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('PROCESGPROC', '', 'CDGRUPROCESSO='||:OLD.CDGRUPROCESSO||';CDPROCESSO='||:OLD.CDPROCESSO||';', SYSDATE);
   END IF;
END;
/
ALTER TABLE PROCESGPROC MODIFY DTULTATUPROGPRO DEFAULT SYSDATE
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_PROCESGPROC','5.01.033'); END;
/

