UPDATE TBDD_BASECONFIG SET DB_VERSION = '1.9.4.0';
USE [DD_ECM]
GO
CREATE FUNCTION [dbo].[FNDD_LANGUAGE_PHRASE](@pTITLE VARCHAR(100),@pLANG_CODE VARCHAR(5), @pMODULE VARCHAR(10))
RETURNS VARCHAR(500)
AS
BEGIN
	DECLARE @RESULT VARCHAR(250), @CTRL_CONFIG_TITLE VARCHAR(100)
	
			SELECT @RESULT = STRING1 FROM TBDD_GUI_LANGUAGE_PHRASE 
			WHERE MODULE = @pMODULE AND TITLE = @pTITLE 
			AND [LANGUAGE] = @pLANG_CODE
			IF LEN(@RESULT) > 0
				SET @RESULT = @RESULT
			ELSE
				BEGIN
					SELECT @RESULT = STRING1 FROM TBDD_GUI_LANGUAGE_PHRASE 
					WHERE MODULE = @pMODULE AND TITLE = @pTITLE 
					AND [LANGUAGE] = 'de-DE'
					SET @RESULT = @RESULT + ' (NoLangConf)' 
				END

	RETURN @RESULT
END
GO
CREATE PROCEDURE [dbo].[PRDD_GUI_LANGUAGE_PHRASE] (@pMODULE VARCHAR(10),@pTITLE VARCHAR(100),@pLANG_CODE VARCHAR(5),@pCAPTION_TYPE VARCHAR(50),@pSTRING1 VARCHAR(900),@pSTRING2 VARCHAR(900),@pWHO VARCHAR(100)
													,@pOBJ_NAME VARCHAR(100),@pINTERNAL BIT)
AS
If NOT EXISTS(SELECT GUID FROm TBDD_GUI_LANGUAGE_PHRASE WHERE [MODULE] = @pMODULE AND TITLE = @pTITLE AND [LANGUAGE] = @pLANG_CODE)
	INSERT INTO [dbo].[TBDD_GUI_LANGUAGE_PHRASE]
           ([MODULE]
           ,[TITLE]
           ,[LANGUAGE]
           ,[CAPT_TYPE]
           ,[STRING1]
		   ,STRING2
           ,[ADDED_WHO]
           ,[OBJ_NAME],INTERNAL) VALUES
			(@pMODULE,@pTITLE,@pLANG_CODE,@pCAPTION_TYPE,@pSTRING1,@pSTRING2,@pWHO,@pOBJ_NAME,@pINTERNAL)
ELSE
	UPDATE [dbo].[TBDD_GUI_LANGUAGE_PHRASE] SET  [CAPT_TYPE] = @pCAPTION_TYPE
           ,[STRING1] = @pSTRING1
		   ,STRING2 = @pSTRING2
           ,CHANGED_WHO = @pWHO
           ,[OBJ_NAME] = @pOBJ_NAME,INTERNAL = @pINTERNAL WHERE 
		   [MODULE] = @pMODULE AND TITLE = @pTITLE AND [LANGUAGE] = @pLANG_CODE
GO