I am working on a Rules Engine for a portion of logic that needs to be editable by the users. This Rules Engine will be dynamic enough for the users to be able to change a lot of the logic without IT intervention. I have the following procedure that gets me the combined logic for one rule:
Results from the above look like:
This works great for one rule at a time. But I need to display all rules in a RuleSet at once on the screen. How can I group this going up one level??? Something like:
Thanks.
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)
Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
Code:
--RuleId passed in as parameter
declare @IfSide varchar(5000)
declare @ThenSide varchar(5000)
select @IfSide = ISNULL(@IfSide + ' AND ' + k.Keyword + ' ' + o.Operator + ' "' + csr.ValueText + '"', k.Keyword + ' ' + o.Operator + ' "' + csr.ValueText + '"')
from dbo.ConfirmSubRules csr
inner join dbo.Keywords k on k.KeywordId = csr.KeywordId
inner join dbo.Operators o on o.OperatorId = csr.OperatorId
where csr.RuleId = @RuleId
and csr.SubRuleTypeId = 1
select @ThenSide = ISNULL(@ThenSide + ' AND ' + k.Keyword + ' ' + csr.ValueText, k.Keyword + ' ' + csr.ValueText)
from dbo.ConfirmSubRules csr
inner join dbo.Keywords k on k.KeywordId = csr.KeywordId
where csr.RuleId = @RuleId
and csr.SubRuleTypeId = 2
select @IfSide 'IfSide', @ThenSide 'ThenSide'
Results from the above look like:
Code:
IfSide ThenSide
Basis equals "no load at NAV & trans fee" Bullet 3204 AND Paragraph 3204 AND Bullet 3205
This works great for one rule at a time. But I need to display all rules in a RuleSet at once on the screen. How can I group this going up one level??? Something like:
Code:
--RuleSetId passed in as parameter
select @IfSide = ISNULL(@IfSide + ' AND ' + k.Keyword + ' ' + o.Operator + ' "' + csr.ValueText + '"', k.Keyword + ' ' + o.Operator + ' "' + csr.ValueText + '"')
from dbo.ConfirmSubRules csr
inner join dbo.Keywords k on k.KeywordId = csr.KeywordId
inner join dbo.Operators o on o.OperatorId = csr.OperatorId
[red]inner join dbo.ConfirmRules r on r.RuleId = csr.RuleId
where r.RuleSetId = @RuleSetId[/red]
and csr.SubRuleTypeId = 1
[red]Group By RuleId[/red]
Thanks.
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)
Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer