MyObj is the definstance for a bean with id as a property.
; Rule that runs once for a definstance.
; Assert a fact so we never do it twice.
(defrule rule-1
(MyObj
(id ?id)
(OBJECT ?obj)
)
(not (id ?id))
=>
(assert (id ?id))
(myfunction1 ?obj)
); Rule for updates.
(defrule rule-2
(MyObj
(id ?id)
(OBJECT ?obj)
)
(id ?id)
=>
(bind ?i (count-query-results find-first-id ?id))
(if (> ?i 0) then
(myfunction2 ?obj)
else
(assert (first-id ?id))
)
)(defquery find-first-id
"Look for first-id fact for id"
(declare (variables ?id))
(first-id ?id)
)-------------------------------------------------------------------- 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] --------------------------------------------------------------------
