0
votes

currently my drools decision table looks like next:

|CONDITION|CONDITION|
---------------------
|      Person       |
---------------------
|name=$1  |age=$1   |
---------------------
|         |         |
---------------------
|a        |22       |
---------------------
|b        |33       |
---------------------

now i want to make this decision table looks like next in .drl file :

rule "1"
when
    exist Person(name=="a",age="22")
then
    do something
end

rule "2"
when 
    Person(name="b", age="33")
then
    do something
end

so how to modify the decision table to achieve my goal?

that is how to use 'exists' keyword in decision table file?

thanks in advance!

1

1 Answers

0
votes
| CONDITION  | CONDITION |
--------------------------
|     exists Person()    |
-------------------------
|name==$param|age==$param|
---------------------
|            |           |
---------------------------
|a           |22         |
---------------------------
|b           |33         |
--------------------------

The other rule is almost the same; just omit the exists. However, one such table can only produce rules according to one template. Therefore, you'll get either two rules (a/22, b/33) with exists, or the same pair without.

To have rules according to both templates, you need two different RuleTables.