CREATE OR REPLACE TRIGGER DTULTATU_PRODSUBSIFILI
BEFORE INSERT OR DELETE OR UPDATE
ON PRODSUBSIFILI 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 ('PRODSUBSIFILI', :OLD.CDFILIAL, 'CDFILIAL='||:OLD.CDFILIAL||';CDPRODUTO='||:OLD.CDPRODUTO||';', SYSDATE);
   END IF;
END;
/

UPDATE PRODSUBSIFILI SET DTULTATU = SYSDATE WHERE DTULTATU IS NULL
/

ALTER TABLE PRODSUBSIFILI MODIFY DTULTATU DEFAULT SYSDATE
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_PRODSUBSIFILI','6.27.000'); END;
/