CREATE OR REPLACE TRIGGER DTULTATU_TPOPERCFOP
BEFORE INSERT OR UPDATE OR DELETE
ON TPOPERCFOP FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATU := SYSDATE;
   END IF;
   IF UPDATING THEN
      IF (NVL(:OLD.IDENTRSAIDOP,0)   <> NVL(:NEW.IDENTRSAIDOP,0))   OR
         (NVL(:OLD.CDTIPOOPER,0)     <> NVL(:NEW.CDTIPOOPER,0))     OR
         (NVL(:OLD.CDFISCOPER,0)     <> NVL(:NEW.CDFISCOPER,0))     OR
         (NVL(:OLD.IDATUESTTPCFOP,0) <> NVL(:NEW.IDATUESTTPCFOP,0)) OR
         (NVL(:OLD.IDCOMPOEVENC,0)   <> NVL(:NEW.IDCOMPOEVENC,0))   THEN
         :NEW.DTULTATU := SYSDATE;
      END IF;
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
      VALUES ('TPOPERCFOP', '', 'IDENTRSAIDOP='||:OLD.IDENTRSAIDOP||';CDTIPOOPER='||:OLD.CDTIPOOPER||';CDFISCOPER='||:OLD.CDFISCOPER||';', SYSDATE);
   END IF;
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_TPOPERCFOP','5.75.xxx'); END;
/
