Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using null in drools rulebase

807599Feb 17 2007 — edited Feb 17 2007
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><a href=");
		ES.resultsmx("http://www.rspb.org.uk/birds/guide/r/robin/index.asp");
		ES.resultsmx(">Robin</a></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><a href=");
		ES.resultsmx("http://www.rspb.org.uk/birds/guide/r/robin/index.asp");
		ES.resultsmx(">Robin</a></p>");
		ES.resultsop();
end
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2007
Added on Feb 17 2007
2 comments
640 views