I discovered the same issue.  Once you call definstance for an object, reset
will update the Jess fact with the Java object, but does not remove it.

I created the following two methods in my Java program to both add and
remove objects, where a corresponding defclass is in the ruleset.  Similar
to you, I used these to take results of a database query and assert them
into Jess.

    public void undefinstance( Rete rete, Object fact ) {
        try {
            // Create the ValueVector (undefinstance <this>)
            ValueVector vv = new ValueVector(2);
            vv.set( new Value(("definstance"), RU.STRING), 0 );
            vv.set( new Value(fact, RU.EXTERNAL_ADDRESS), 1 );
           
            Userfunction undefinst = rete.findUserfunction("undefinstance");
            undefinst.call(vv, rete.globalContext());
        } catch (ReteException re) {
            re.printStackTrace(System.out);
        }
    }

    public void definstance( Rete rete, Object fact ) {
        try {
            // Create the ValueVector (definstance Foo <this>)
            ValueVector vv = new ValueVector(3);
            vv.set( new Value(("definstance"), RU.STRING), 0 );
            vv.set( new Value(fact.getClassName(), RU.STRING), 1 );
            vv.set( new Value(fact, RU.EXTERNAL_ADDRESS), 2 );
           
            Userfunction definst = rete.findUserfunction("definstance");
            definst.call(vv, rete.globalContext());
        } catch (ReteException re) {
            re.printStackTrace(System.out);
        }
    }

At 12:00 PM 10/21/98 -0500, you wrote:
>I've created a loop in which I read a record from an oracle database,
>create a java bean class, set a variable (which has been defclass'd
>within a jess file).  Then I call reset, Funcall (to call the
>definstance
>function to pass in the object), then call run.
>
>My question is:  am I using the reset properly?  I thought that by
>calling reset, it would erase the previous definstance, so that the
>engine would run only on the current definstance.  I put in a (watch
>all),
>and it is showing that I'm collecting all the instances, and the engine
>is firing upon them all each time I call run.
>
>Is there some other way I'm supposed to delete the definstances?
>
>Thanks for any help,
>
>KathyLee Simunich
>Decision & Information Sciences Division
>Argonne National Lab
>
>----code segment follows-----
>
>        for (int i= 0; i < numrecs; i++) {
>            ccc = (String)fieldReturns[0].get(i);  // field from oracle
>db
>
>            // create the bean
>            tRec = new TRecord();
>            tRec.setCCC(ccc);
>
>            // assert the facts, and execute manually.
>            try {
>                rete.executeCommand("(reset)");
>
>                // Tell Jess about the bean
>                Funcall f = new Funcall("definstance", rete);
>                f.add(new Value("tRec", RU.ATOM));
>                f.add(new Value(tRec, RU.EXTERNAL_ADDRESS));
>                f.simpleExecute(f, rete.globalContext());
>
>                // now run on the new definstance
>                rete.executeCommand("(run)");
>            } catch (ReteException re) {
>                re.printStackTrace(nd.stderr());
>            }
>        }
>
>
>---------------------------------------------------------------------
>To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
>in the BODY of a message to [EMAIL PROTECTED], NOT to the
>list. List problems? Notify [EMAIL PROTECTED]
>---------------------------------------------------------------------
>
>

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to