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

UPDATE SETORLOJA SET DTULTATU = SYSDATE WHERE DTULTATU IS NULL
/

ALTER TABLE SETORLOJA MODIFY DTULTATU DEFAULT SYSDATE
/

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