Hi!

> BTW, I have looked at the mailing list archives and also
> the Fact Storage Provider Framework.  The latter I have
> really had problems understanding what it really does.

The framework could help you with your task.

Assuming you have initialized the providers for the 'scott' database schema. You can 
then automatically create deftemplates and activate backward chaining for all the 
tables in that schema with just the following command:

        (fsm-define-backchain-reactive (fsm-describe scott))

For the sample scott schema that comes with an Oracle RDBMS that command will create, 
among others, the following deftemplates (simplified):

        (deftemplate scott-emp
           (slot empno (type INTEGER))
           (slot ename (type STRING))
           (slot deptno (type INTEGER)))

        (deftemplate scott-dept
           (slot deptno (type INTEGER))
           (slot dname (type STRING))
           (slot loc (type STRING)))

Now let's say you have some sort of goal fact:

        (deftemplate process-scott-emp 
           (slot empno (type INTEGER)))

You can then write the following rule:

        (defrule process-employees
           (process-scott-emp (empno ?empno))
           (scott-emp (empno ?empno) (ename ?ename) (deptno ?deptno))
           (scott-dept (deptno ?deptno) (dname ?dname) (loc ?loc))
           =>
           (printout t "Emp " ?ename " works in dept " ?dname crlf))

When you assert process-scott-emp facts and run the engine the framework will 
automatically query your database and assert the corresponding scott-emp and 
scott-dept facts. Example:

        (assert (process-scott-emp (empno 1)))
        (run)

This might produce facts like

        (scott-emp (empno 1) (ename "Thomas") (deptno 100))
        (scott-dept (deptno 100) (dname "BTO") (loc "Zurich"))

By calling

        (expand (assert (fsm-select (need-scott-emp))))

you would execute a query 

        SELECT * FROM scott.emp

and assert a fact for each record in the result set.

So that's at least part of what the framework does.

Greetings, Thomas
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to