Variable Definition
Use
Variable definitions are those whose value can be assigned in actions of rules. You can create variable definitions on primitive data types and Java objects.
For more information, see Definition
Example
-
Consider a variable definition as follows:
Name
Type
Initial Value
interest rate
int
0
This variable definition can be used in an action in an if-then rule as follows:
If
...
Then
Assign:: interest rate = interest rate + 10
Typical Uses
-
Many rules involve calculation of a crucial output parameter that is modified by other rules. In such cases the output parameters can be modified in those rules.
-
Some actions may return intermediate values that need to be used as input for other actions. This can be achieved by using variable definitions.
Clarifications
Variable definitions can be used in conditions. When variable definition used in Assign action cause the values of those variable definitions to change, then these definitions used in conditions are re-evaluated . Based on the outcome then rules are appropriately removed from or added to the firing queue. Firing queue represents a collection of actions of all satisfied rules that are to be fired by the rule engine