insert and its cousins all depend on a context where the variable drools is
defined and supplie by the parser, and this is restricted to consequence code.
import org.drools.runtime.KnowledgeContext;
function makeFact( KnowledgeContext kContext, ... ){
Fact f = new Fact( ... );
kContext.getKnowledgeRuntime().insert( f );
}
then
makeFact( kcontext, ... );
end
-W
On 07/02/2012, Shur, Bob <[email protected]> wrote:
> It seems I am unable to insert a new fact from within a drl function. I
> tried this:
>
> ////////////////////////
> package com.sample
>
> declare Dummy
> end
>
> function void init() {
> insert(new Dummy()); // Doesn't compile
> }
>
> rule "init"
> salience 999
> when
> then
> init();
> insert(new Dummy()); // Compiles
> end
>
> ////////////////////////
>
> Is the above supposed to work?
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users