[rules-users] using null in drools rulebase
mike20043
mintymike20043 at yahoo.co.uk
Sat Feb 17 06:51:00 EST 2007
my bad, i copied the code from the wrong version. it should of been
Beak(beak == "small beak") || Beak(beak == null)
and it evaluates to false even if beak is null or dosent exist.
i have also tried using =null but i get a error message saying unexpected
token'beak'.
strangely if i use !=null it does accept it and im just stumped.
mike.
Edson Tirelli-3 wrote:
>
>
> Mike,
>
> The implicit connective constraint is AND, so if you write:
>
> when
> Beak(beak == "small beak", beak = null)
>
>
> You are saying:
>
> When beak is "small beak" AND beak is null...
>
> Which will always evaluate to false.
>
> []s
> Edson
>
> mike20043 wrote:
>
>>hi everyone
>>
>>need a bit more help here. im currently attempting to write some rules
into
>>my rulesbase and can't seem to get the system to check if a variable is
>>empty. i have tried using null as shown in the code below
>>
>>
>>rule "small beak + small body + garden"
>> when
>> Beak(beak == "small beak", beak = null) &&
>> Body(body == "small body")
>> Location(location == "garden")
>> then
>> ES.resultsmx("<p> );
>> ES.resultsmx( Robin </p>");
>> ES.resultsop();
>>end
>>
>>
>>
>>which dosent work but for some reason i am able to check if it is not null
>>by doing this
>>
>>
>>rule "small beak + small body + garden"
>> when
>> Beak(beak == "small beak", beak != null) &&
>> Body(body == "small body")
>> Location(location == "garden")
>> then
>> ES.resultsmx("<p> );
>> ES.resultsmx( Robin </p>");
>> ES.resultsop();
>>end
>>
>>
>>
>>I have tired using == null but this returns a false and the rule dosent
run.
>>can anyone help me please. Also if anyone has any knowledge of how to
write
>>rules so it only outputs one result instead of repeatedly running the
>>conditions and outputting results for each correct condition and also how
to
>>check if a string variable contains a substring (within a rule) that would
>>be greatly appreciated . Thanks in advance
>>
>>mike
>>
>>
>
>
> --
> Edson Tirelli
> Software Engineer - JBoss Rules Core Developer
> Office: +55 11 3124-6000
> Mobile: +55 11 9218-4151
> JBoss, a division of Red Hat @ www.jboss.com
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/using-null-in-drools-rulebase-tf3244300.html#a9019052
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list