/******************************************************************************/
/*                                                                            */
/* Trigger: DTULTATU_TIPOSANGRIA                                              */
/* Tabela : TIPOSANGRIA                                                       */
/*                                                                            */
/* Criação:                                                                   */
/* 09/05/2011 - LUCIANA CORREA                                                */
/*                                                                            */
/******************************************************************************/

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

ALTER TABLE TIPOSANGRIA MODIFY DTULTATU DEFAULT SYSDATE
/

UPDATE TIPOSANGRIA SET DTULTATU = SYSDATE WHERE DTULTATU IS NULL
/

-- VERSAO --
BEGIN ATUVEROBJ('DTULTATU_TIPOSANGRIA','5.20.000'); END;
/