<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=498355614-21082008><FONT face=Arial
color=#0000ff size=2>You could use a global as OutputObject instead of a Fact.
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=498355614-21082008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=498355614-21082008></SPAN><SPAN
class=498355614-21082008><FONT face=Arial color=#0000ff size=2>If you want to
use properties of OutputObject in a LHS pattern you'll need to use "from" but
this is not indexed and so using the two rules with a fact approach might give
better performance in this case.</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>thomas
kukofka<BR><B>Sent:</B> 21 August 2008 15:03<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> [rules-users] object creation<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>Hello,<BR><BR>I have a rule which creates an object in the
consequence part and updates this object each time teh rule is executed. So
the object has to be created only the first time.<BR>So I always need two
rules, one init rule which creates the object if it doesn't exist yet and one
if it already exists and it should only be updated:<BR><BR>rule "init
rule"<BR>when<BR> "condition"<BR> AND <BR>
not OutputObject()<BR>then<BR> OutputObject oo = new
OutputObject();<BR> insert(oo);<BR><BR>rule "update
rule"<BR>when<BR> "condition"<BR> AND <BR>
oo: OutputObject()<BR>then<BR> #do something with the
object<BR> update(oo);<BR><BR>But is it really neccessary to write
an extra rule only to create the output-fact initially? Is it possible/good
style to make this in one single rule? <BR><BR>Appreciate your
help.<BR><BR>Regards<BR>Thomas<BR></DIV></BLOCKQUOTE></BODY></HTML>