While running Jess Version 7.0p1 12/21/2006, accessing defquery results fails
with a compound pattern that works with a defrule.
Bob Kirby
----------------
(deftemplate row
"A row in a test table."
(declare (ordered FALSE))
(slot primary (type SYMBOL))
(slot foreign (type SYMBOL)))
(deffacts rows
"Rows of a test table of primary and foreign keys."
(row (primary first) (foreign key1))
(row (primary second) (foreign unmatched)))
(deftemplate pair
"A pair of a key and a value."
(declare (ordered FALSE))
(slot key (type SYMBOL))
(slot val (type STRING)))
(deffacts pairs
"Pairs of keys and values including a default value."
(pair (key key1) (val val1))
(pair (key default) (val default-val)))
(defrule print-test-rule
"Test to print results from a rule"
(row (primary ?primary) (foreign ?foreign))
(or (pair (key ?foreign) (val ?val))
(and (not (pair (key ?foreign)))
(pair (key default) (val ?val))))
=>
(printout t "print-test-rule " ?primary " " ?foreign " " ?val crlf))
(reset)
(run)
;;;print-test-rule second unmatched default-val
;;;print-test-rule first key1 val1
(defquery test-query
"A test query to assign defaults for foreign keys."
(row (primary ?primary) (foreign ?foreign))
(or (pair (key ?foreign) (val ?val))
(and (not (pair (key ?foreign)))
(pair (key default) (val ?val)))))
(deffunction print-test-query ()
"Run test-query"
(bind ?results (run-query* test-query))
(while (?results next)
(printout t "print-test-query "
(?results getString primary) " "
(?results getString foreign) " "
(?results getString val) crlf))
(?results close))
(print-test-query)
Jess reported an error in routine Context.getReturn
while executing (call ?results getString val)
while executing (printout t "print-test-query " (call ?results
getString primary) " " (call ?results getString foreign) " " (call ?results
getString val) crlf)
while executing (while (call ?results next) (printout t
"print-test-query " (call ?results getString primary) " " (call ?results
getString foreign) " " (call ?results getString val) crlf))
while executing deffunction print-test-query
while executing (print-test-query)
while executing (batch q.clp).
Message: No such variable val.
Program text: ( batch q.clp ) at line 1.
--------------------------------------------------------------------
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]
--------------------------------------------------------------------