Pages

Friday, January 3, 2020

Cannot create a business rule in MDM (Master Data Services) 2019

If you have upgraded your MDM(Master Data Services)
to SQL Server 2019 with compatibility level 150,
For example from version 2017.
and you have user-defined scripts(functions / stored procedures) that you use,
most probably you will not be able to add a new business rule via the MDM website.

In my case, I get disabled dropdowns as below without any errors in UI,
The "Attribute" drop-down is not accessible and completely disabled
and the "Operator" drop-down is empty:






















The reason for this is bugs in the SQL Server 2019,
see my post.

A quick solution will be to switch back to compatibility level 140 or lower
or to adjust the [mdm].[udfScriptExists] function not to return the error

Subquery returned more than 1 value. 
This is not permitted when the subquery follows =, !=, <, <= , >, >= 
or when the subquery is used as an expression.

See my post on how to.

The issue is the following code in the [mdm].[udfScriptExists]  function

SELECT @Result = 0      
FROM sys.parameters      
WHERE object_id = @ScriptObjectId      
             AND ((is_output = 1 AND user_type_id <> TYPE_ID('bit'))      
              OR (is_output = 0 AND     
                        ( user_type_id NOT IN (TYPE_ID('nvarchar'),TYPE_ID('datetime2'), TYPE_ID('decimal')) -- ONLY SUPPORT TYPE NVARCHAR, DATETIME2, AND DECIMAL    
                        OR (user_type_id = TYPE_ID('decimal') AND ([precision] <>38 OR scale>7)))))  -- IF TYPE IS DECIMAL, PRECISION SHOULD BE 38 WHICH IS THE DEFAULT ONE ,AND SCALE SHOULD BE IN THE ARRANGE OF 0 TO 7 


SELECT @Result = 0
FROM sys.parameters WHERE object_id = @ScriptObjectId
AND (
(parameter_id = 1 AND (TYPE_NAME(user_type_id) <> 'MemberId' OR name <>N'@MemberIdList' COLLATE DATABASE_DEFAULT))
OR(parameter_id = 2 AND (TYPE_NAME(user_type_id) <>'nvarchar' OR max_length <> -1 OR name <>N'@ModelName' COLLATE DATABASE_DEFAULT))
OR(parameter_id = 3 AND (TYPE_NAME(user_type_id) <>'nvarchar' OR max_length <> -1 OR name <>N'@VersionName' COLLATE DATABASE_DEFAULT))
OR(parameter_id = 4 AND (TYPE_NAME(user_type_id) <>'nvarchar' OR max_length <> -1 OR name <>N'@EntityName' COLLATE DATABASE_DEFAULT))
OR(parameter_id = 5 AND (TYPE_NAME(user_type_id) <>'nvarchar' OR max_length <> -1 OR name <>N'@BusinessRuleName' COLLATE DATABASE_DEFAULT))
)

No comments:

Post a Comment