Variables can be used in rules as conditions and as conclusions. For example, you might want to prove the person's age (a number) from a person's date of birth (a date) and perhaps use this attribute as a condition determining whether the person is over the age of 18 (a boolean).
Specify the value for a variable in a rule
Use a variable in a mathematical calculation in a rule conclusion
Use a variable in a straight calculation in a rule calculation
To avoid ambiguity, the Oracle Policy Modeling compiler enforces strict formatting on the values of variables where the value is explicitly used in a rule. For the formatting requirements and other considerations when setting the value of a variable in a rule, see Use constant values in rules.
Like boolean attributes, variables can be used as conditions in any rule proving another attribute. When using variables in conditions you must state the value, or range of acceptable values, that are sufficient to satisfy the condition. To do this, you must use one of the standard logical operators. The value of the attribute may either be compared to a fixed value ("= 18") or to the value of another attribute ("= the spouse's date of birth").
NOTE: Where two variable attributes are being compared, they must be of the same variable type. When comparing a variable attribute with a constant value, the value must be in the specified format for that type of variable attribute. See Use constant values in rules for more information.
Operator | Example |
---|---|
Greater than (>) |
|
Less than (<) |
|
Equals (=) |
|
Not equal to (<>) |
|
Greater than or equal to (>=) |
|
Less than or equal to (<=) |
|
It is possible to perform a variety of mathematical calculations using variables. These operations include:
For the full list of supported operators and functions, see Numerical functions in the function reference.
For example,
the cost of the school lunch = the cost of the meat pie + the cost of the bag of the chips + the cost of the soft drink - the amount of the student discount
the person's share of household income = (the person's income + the partner's income)/2
TIP: Whilst the standard mathematical preference is applied to operators in the absence of parentheses (ie division, multiplication, addition, subtraction), you should make the order explicit with the use of parentheses.
In the same way that a boolean attribute is set to a value when used in a rule conclusion, a variable can be assigned a value in a conclusion. For example, for the variable "the passenger’s allowance in Australian dollars" we can write the following rule:
the passenger's allowance in Australian dollars = 350
In this case, no conditions are required so the value is always inferred. Therefore, no alternative conclusion is produced.
See also