13.41. The Modify Statement

Table 13.6. The Modify Statement

Name Description Syntax Example
modify
This provides a structured approach to fact updates. It combines the update operation with a number of setter calls to change the object's fields.
modify ( <fact-expression> ) {
    <expression> [ , <expression> ]*
}
The parenthesized <fact-expression> must yield a fact object reference. The expression list in the block should consist of setter calls for the given object, to be written without the usual object reference, which is automatically prepended by the compiler.
rule "modify stilton"
when
    $stilton : Cheese(type == "stilton")
then
    modify( $stilton ){
        setPrice( 20 ),
        setAge( "overripe" )
    }
end