IF EXISTS(SELECT * FROM sysobjects O, sysusers U
          WHERE
            o.name = 'DTULTATU_CONFTELACAIXA'  and
            type = 'TR'                 and
            u.uid = o.uid               and
            u.name = USER)
  DROP TRIGGER DTULTATU_CONFTELACAIXA
  GO

CREATE TRIGGER DTULTATU_CONFTELACAIXA
ON CONFTELACAIXA
FOR INSERT, UPDATE
AS
BEGIN
   UPDATE CONFTELA
      SET DTULTATUCFTE = GETDATE()
     FROM INSERTED 
    WHERE CONFTELA.NRCONFTELA = INSERTED.NRCONFTELA
      AND CONFTELA.CDFILIAL = INSERTED.CDFILIAL
      AND CONFTELA.DTINIVIGENCIA = INSERTED.DTINIVIGENCIA;

   UPDATE ITMENUCONFTE
      SET DTULTATUITCT = GETDATE()
     FROM INSERTED
    WHERE ITMENUCONFTE.CDFILIAL   = INSERTED.CDFILIAL
      AND ITMENUCONFTE.NRCONFTELA = INSERTED.NRCONFTELA
      AND ITMENUCONFTE.DTINIVIGENCIA = INSERTED.DTINIVIGENCIA;
END;
GO

-- VERSAO --
EXEC ATUVEROBJ 'DTULTATU_CONFTELACAIXA','6.39.010';
GO
