[英]TSQL list of business rules in MDS
I need help with querying my business rules in SQL! 我需要查询SQL中的业务规则的帮助!
I have created couple of business rules in MDS web service to validate my master data and found out that 2 % of my data is not complying with the rules. 我已经在MDS Web服务中创建了几个业务规则来验证我的主数据,并发现我的数据中有2%不符合规则。 Now I have created a SQL subscription view to report on the invalid data in PowerBI.
现在,我已经创建了一个SQL订阅视图,以报告PowerBI中的无效数据。 In my PowerBI report I need to tell the business user why the data is invalid but I cannot since the subscription view only tells where the data is invalid but not why the data is invalid.
在我的PowerBI报告中,我需要告诉业务用户为什么数据无效,但是我不能告诉用户,因为订阅视图仅表明数据无效的地方,而不是为什么数据无效的原因。 So I need to know how I might query my business rules from MDS database in SQL and map it with my PowerBI data model.
因此,我需要知道如何从SQL中的MDS数据库查询业务规则,并将其与PowerBI数据模型进行映射。 Is there a way to query the list of business rules from MDS database?
有没有一种方法可以从MDS数据库查询业务规则列表?
OK, so there are multiple ways to go about this. 好的,因此有多种方法可以解决此问题。 Here are some solutions, pls choose one that suits your scenario.
这里有一些解决方案,请选择一种适合您的方案。
The following query will retrieve the list of all Active Business Rules created in MDS. 以下查询将检索在MDS中创建的所有活动业务规则的列表。
SELECT *
FROM [MDM].[mdm].[viw_SYSTEM_SCHEMA_BUSINESSRULES]
WHERE Model_Name = 'YourModelName'
AND BusinessRule_StatusName = 'Active'
You can, of course, further filter by Entity_Name
, etc. The important columns in your case are going to be: 当然,您可以按
Entity_Name
等进一步过滤。在您的情况下,重要的列将是:
[BusinessRule_Name]
[BusinessRule_Description]
[BusinessRule_RuleConditionText]
[BusinessRule_RuleActionText]
Note: The challenge in your scenario, I think, is going to be that the Subscription View of the entity does not have IDs of the exact Business Rules that failed. 注意:我认为,您的方案所面临的挑战将是该实体的“订阅视图”不具有失败的确切业务规则的ID。 So I'm not sure how you'll tie these 2 together (failing Rows -> List of Business Rules).
因此,我不确定您如何将这两个捆绑在一起(失败行->业务规则列表)。 Also remember that each row may have more than 1 business rule that failed.
还要记住,每一行可能有多个失败的业务规则。
viw_SYSTEM_USER_VALIDATION
viw_SYSTEM_USER_VALIDATION
This is a view that has a historical list of all business rules (+row info) that failed. 此视图具有所有失败的业务规则(+行信息)的历史列表。 You may use the view in this way:
您可以通过以下方式使用视图:
SELECT
DISTINCT ValidationIssue_ID, Version_ID, VersionName, Model_ID, ModelName, Entity_ID, EntityName, Hierarchy_ID, HierarchyName, Member_ID, MemberCode, MemberType_ID, MemberType, ConditionText, ActionText, BusinessRuleID, BusinessRuleName, PriorityRank, DateCreated, NotificationStatus_ID, NotificationStatus
FROM [MDM].[mdm].[viw_SYSTEM_USER_VALIDATION]
WHERE --CAST(DateCreated as DATE) = CAST(GETDATE() as DATE) AND
ModelName = 'YourModelName'
--AND EntityName IN ('Entity_1','Entity_2') -- Use this to Filter on specific Entities
Here, use the columns Model_ID
, Entity_ID
and Member_ID
/ MemberCode
to identify the specific model, entity & row that failed. 在这里,使用
Model_ID
, Entity_ID
和Member_ID
/ MemberCode
来标识失败的特定模型,实体和行。
Columns BusinessRuleName
, ConditionText
& ActionText
will give your users additional info on the Business Rule that failed. 列
BusinessRuleName
, ConditionText
和ActionText
将为您的用户提供有关失败的业务规则的其他信息。
Note: 注意:
DateCreated
). DateCreated
列)。 <--CAST(DateCreated as DATE) = CAST(GETDATE() as DATE) AND>
does the same. <--CAST(DateCreated as DATE) = CAST(GETDATE() as DATE) AND>
执行相同的操作。 If you can't use that, just make sure the data row are distinct. My suggestion would be to use a slightly modified version of Solution #2: 我的建议是使用解决方案2的稍作修改的版本:
Get the list of Failed Rows from your Subscription View (the data row's ValidationStatus is actually still 'Failed' ), then JOIN with viw_SYSTEM_USER_VALIDATION
making sure that you only select the row with MAX(DateCreated)
value (of course for the same data row AND Business Rule). 从您的订阅视图中获取失败行的列表(数据行的ValidationStatus实际上仍为 'Failed' ),然后使用
viw_SYSTEM_USER_VALIDATION
进行联接,以确保仅选择具有MAX(DateCreated)
值的行(当然,同一数据行并业务规则)。
Best of luck and if you find anything else while solving this issue, do share your learning here with all of us. 祝您好运,如果您在解决此问题时发现任何其他问题,请与我们所有人分享您的经验。
Lastly, if you found this useful, pls remember to Mark it as the Answer :) 最后,如果您发现此功能有用,请记住将其标记为答案:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.