updateRule
Syntax
updateRule(engineName, key, rules)
Arguments
engineName is a STRING scalar indicating the engine name.
key is a scalar of STRING or INT type that specifies the key of rule set to be updated.
rules is a tuple of metacode indicating the rules to be updated.
Details
If the specified key already exists in the rule engine, update the corresponding value with rules;
If the key does not exist in the rule engine, add the rules.
Return value: true if successful, otherwise false.
Examples
// create a rule engine x = [1, 2, NULL] y = [ [ < value>1 > ], [ < price<2 >, < price>6 > ], [ < value*price>10 > ] ] ruleSets = dict(x, y) names = `sym`value`price`quatity types = [INT, DOUBLE, DOUBLE, DOUBLE] dummy = table(10:0, names, types) outputNames = `sym`value`price`rule outputTypes = [INT, DOUBLE, DOUBLE, BOOL[]] outputTable = table(10:0, outputNames, outputTypes) test = createRuleEngine("ruleEngineTest",ruleSets,dummy ,`sym`value`price, outputTable, "all",`sym) test.append!(table(1 as sym, 0 as value, 2 as price, 3 as quatity)) test.append!(table(3 as sym, 6 as value, 1 as price, 3 as quatity)) // outputTable 1 0 2 [false] 3 6 1 [false] // modify the rule for sym=1 to value >=0 updateRule("ruleEngineTest", 1, [ <value >= 0>]) test.append!(table(1 as sym, 0 as value, 2 as price, 3 as quatity)) // outputTable 1 0 2 [true] // add the rule value > 5 for sym=3 updateRule("ruleEngineTest",3,[<value>5>]) test.append!(table(3 as sym, 6 as value, 1 as price, 3 as quatity)) // outputTable 3 6 1 [true]