CREATE OR REPLACE TRIGGER DTULTATU_VOUCHERVND
BEFORE INSERT OR DELETE OR UPDATE
ON VOUCHERVND 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 ('VOUCHERVND', '', 'CDCAMPANHA='||:OLD.CDCAMPANHA||';NRSEQVOUCHER='||:OLD.NRSEQVOUCHER||';', SYSDATE);
   END IF;
END;
/

UPDATE VOUCHERVND SET DTULTATU = SYSDATE WHERE DTULTATU IS NULL
/

ALTER TABLE VOUCHERVND MODIFY DTULTATU DEFAULT SYSDATE
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_VOUCHERVND','5.75.000'); END;
/