UPDATE TBDD_MODULES SET DB_VERSION = '1.9.5.0' where NAME = 'Process-Manager'
GO

ALTER FUNCTION [dbo].[FNPM_LAST_EDITED_DOC](@pPROFIL_ID INTEGER,@pDOC_ID INTEGER)
RETURNS DATETIME
AS
BEGIN
	DECLARE @RESULT DATETIME
	IF EXISTS(SELECT GUID FROM TBPM_FILES_WORK_HISTORY WHERE PROFIL_ID = @pPROFIL_ID AND DOC_ID = @pDOC_ID)
		SELECT @RESULT = WORKED_WHEN FROM TBPM_FILES_WORK_HISTORY WHERE GUID = 
			(SELECT MAX(GUID) FROM TBPM_FILES_WORK_HISTORY WHERE PROFIL_ID = @pPROFIL_ID AND DOC_ID = @pDOC_ID) 
	ELSE
		SELECT @RESULT = convert(date,T.DMS_ERSTELLT_DATE)  FROM TBPM_PROFILE_FILES T 
		WHERE T.PROFIL_ID = @pPROFIL_ID AND T.DOC_ID = @pDOC_ID
	RETURN @RESULT
END
GO


