-- Licensed Materials - Property of IBM
-- BI and PM: Mobile
-- (C) Copyright IBM Corp. 2007, 2012
-- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

CREATE TRIGGER [TGR_MOB_UR_SYNC_UP] ON [MOB_USER_RENDER]
AFTER UPDATE 
AS
BEGIN
	DECLARE @ur_user_id int
	IF (SELECT COUNT(*) FROM inserted) > 0
	BEGIN
		SELECT @ur_user_id = USER_ID
			FROM inserted
		UPDATE MOB_USERS SET LAST_UPDATED = GETDATE() 
			WHERE USER_ID = @ur_user_id;
	END;
	ELSE
	BEGIN
		SELECT @ur_user_id = USER_ID
			FROM deleted
		UPDATE MOB_USERS SET LAST_UPDATED = GETDATE() 
			WHERE USER_ID = @ur_user_id;
	END;
END;
