규칙 변수에서 규칙 조치의 종속성
규칙이 해당 변수를 인스턴스화할 수 없는 경우에는 규칙의 조치를 실행할 수 없습니다.
규칙의 definitions 및 when 파트에서 규칙 변수를 정의합니다. 해당 변수를 인스턴스화할 수 없는 경우, 즉 변수가 기존 데이터와 일치하지 않는 경우에는 규칙이 조치를 수행할 수 없습니다.
규칙에 변수 및 조건이 있는 경우, 변수가 인스턴스화될 수 있으며 조건이 참이 아닐 때만 규칙이 else 파트를 적용할 수 있습니다.
모든 고객이 5% 이상의 할인을 받기 때문에 다음 규칙은 항상 할인율을 적용합니다.
if all of the following conditions are true:
- the value of the shopping cart of 'the customer' is more than 100
- the category of 'the customer' is Gold
then
print "apply a 15% discount";
else
print "apply a 5% discount";
그러나 골드 카테고리의 고객에게만 할인을 제공하는 definitions 파트를 사용하여 규칙을 변경할 수 있습니다.
when a purchase event occurs
definitions
set 'the customer' to the customer of this purchase event
where the category of this customer is Gold;
if the value of the shopping cart of 'the customer' is more than 100
then
print "apply a 15% discount";
else
print "apply a 5% discount";
또한 구매 금액이 200을 초과하는 고객에게만 할인을 제공하는 when 절을 사용하여 규칙을 변경할 수도 있습니다.
when a purchase event occurs
where the amount of this purchase event is more than 200
if the category of 'the customer' is Gold
then
print "apply a 15% discount";
else
print "apply a 5% discount";