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

CREATE TRIGGER DTULTATU_TPOPERCFOP
ON TPOPERCFOP
FOR INSERT, UPDATE, DELETE
AS
BEGIN
   IF (0 = (SELECT COUNT(*) FROM INSERTED)) BEGIN
      INSERT INTO DELETECACHE (NMTABLECACHE, CDFILICACHE, DSKEYCACHE, DTULTATUCACH)
		(SELECT 'TPOPERCFOP', null, 'IDENTRSAIDOP='+ IDENTRSAIDOP + ';'+'CDTIPOOPER='+ CDTIPOOPER + ';' + ';'+'CDFISCOPER='+ CDFISCOPER + ';', CONVERT(DATETIME,CONVERT(VARCHAR,GETDATE(),103)+' '+CONVERT(VARCHAR,GETDATE(),108)) FROM DELETED)
   END
   ELSE BEGIN
      UPDATE TPOPERCFOP
      SET DTULTATU = CONVERT(DATETIME,CONVERT(VARCHAR,GETDATE(),103)+' '+CONVERT(VARCHAR,GETDATE(),108))
      FROM INSERTED
      WHERE (ISNULL(TPOPERCFOP.IDENTRSAIDOP ,0) = ISNULL(INSERTED.IDENTRSAIDOP, 0));
   END;
END;
GO

-- VERSAO --
EXEC ATUVEROBJ 'DTULTATU_TPOPERCFOP','5.75.XXX';
GO