UPDATE TBDD_MODULES SET DB_VERSION = '2.5.0.3' where NAME = 'Record-Organizer' 
GO 
ALTER TABLE [dbo].[TBPMO_KONFIGURATION] ADD  WMPATH_PREFIX VARCHAR(100) NOT NULL DEFAULT '\\WINDREAM\OBJECTS'
GO
ALTER FUNCTION [dbo].[FNPMO_GET_WINDREAM_FILE_PATH] (@pDOCID BIGINT)
RETURNS VARCHAR(MAX)
AS 
BEGIN
	DECLARE	
		@RESULT					VARCHAR(MAX),
		@DOCID					BIGINT,
		@a						BIGINT = 1,
		@i						BIGINT = 0,
		@PARENT_ID				BIGINT,
		@DATEINAME				NVARCHAR(255),
		@PARENTNAME				NVARCHAR(255),
		@FSFLAGS				INT--,
		--@WM_LAUFWERKBUCHSTABE	CHAR(1)		,
		--@SHAREPATH				VARCHAR(100)
	
--	SELECT @WM_LAUFWERKBUCHSTABE = WM_LAUFWERKBUCHSTABE	FROM TBPMO_KONFIGURATION WHERE GUID = 1

	--SELECT @SHAREPATH = WMPATH_PREFIX FROM TBPMO_KONFIGURATION WHERE GUID = 1;
	SELECT @FSFLAGS = dwFSFlags FROM [SDD-VMP04-SQL17\DD_DEVELOP01].[sDD_VMP01_APS01_windream60].dbo.BaseAttributes WHERE dwDocID = @pDOCID
	IF @FSFLAGS = 16
		BEGIN
			SET @RESULT = 'THIS IS NOT A FILE!'
		END
	ELSE
		BEGIN
			SELECT @DATEINAME = szLongName,@PARENT_ID = dwParentID FROM [SDD-VMP04-SQL17\DD_DEVELOP01].[sDD_VMP01_APS01_windream60].dbo.BaseAttributes WHERE dwDocID = @pDOCID
			WHILE @a > 0
				BEGIN
					IF @i = 0
						BEGIN
							IF @PARENT_ID = 1
								BEGIN
									SET @RESULT = '\'
									BREAK
								END
							ELSE
								BEGIN
									SET @DOCID = @PARENT_ID
									SET @RESULT = '\'
								END
						END
					ELSE
						BEGIN
							IF @PARENT_ID = 1
								BEGIN
									SET @RESULT = '\' + @PARENTNAME + @RESULT
									BREAK
								END
							ELSE
								BEGIN
									SET @DOCID = @PARENT_ID
									SET @RESULT = '\' + @PARENTNAME + @RESULT
								END
						END	
					
					SELECT @PARENTNAME = szLongName,@PARENT_ID = dwParentID FROM [SDD-VMP04-SQL17\DD_DEVELOP01].[sDD_VMP01_APS01_windream60].dbo.BaseAttributes WHERE dwDocID = @DOCID
					SET @i = @i + 1
				END
		END
	
	SET @RESULT = --@SHAREPATH +  
	@RESULT + @DATEINAME
	RETURN @RESULT
END

GO


