CREATE OR REPLACE TRIGGER DTULTATU_MOVBENEFICIOCTR
BEFORE INSERT OR DELETE OR UPDATE
ON MOVBENEFICIOCTR FOR EACH ROW

BEGIN
   IF INSERTING THEN
      :NEW.DTULTATU := SYSDATE;
   END IF;
   IF UPDATING THEN
      :NEW.DTULTATU := SYSDATE;
   END IF;
   IF DELETING THEN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
                       VALUES ('MOVBENEFICIOCTR', '', 'CDCLIENTE='||:OLD.CDCLIENTE||';CDCONSUMIDOR='||:OLD.CDCONSUMIDOR||';CDCAMPANHA='||:OLD.CDCAMPANHA||';NRSEQPRODCAMP='||:OLD.NRSEQPRODCAMP||';NRSEQBENEFICIO='||:OLD.NRSEQBENEFICIO||';', SYSDATE);
   END IF;
END;
/

UPDATE MOVBENEFICIOCTR SET DTULTATU = SYSDATE WHERE DTULTATU IS NULL
/

ALTER TABLE MOVBENEFICIOCTR MODIFY DTULTATU DEFAULT SYSDATE
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_MOVBENEFICIOCTR','6.05.000'); END;
/
