[rules-users] Re: can not be updated variable value

Alexander Claus styjdt at claus4joy.de
Thu Jun 19 05:29:52 EDT 2008


> Thanks Alexander.
>
> my question is in my table empcode colunm value first i am set some value
> like this empcode="EMPCODE"
> when a set some value in my TestCase's like...emp.setEmpCode("manya");
> In this case it will change column value like this...
> empcode="manya".But,condition is column value can not be updated.
>
>
> condition is LHS:   empcode can not be updated.
> RHS: > System.out.println("empcode can not be updated")
>
> Thanks,
> Manya....

The question is, why can the value not be updated, and when do you expect to 
recognize it.

Do you want to call emp.setEmpCode("manya") in the rhs of your rule? Then 
probably, you could model this method as to return true, if the value was 
changed and false otherwise. Depending on the return value of the method you 
can make the console output in the rhs. Of course, this is conditional code, 
which should be avoided in the rhs of rules, but in this case it depends on 
stuff, which can only be done in the rhs (set..)

If you want to set the empcode somewhere else outside of Drools and you want 
some rules to inform you about the failing of this assignment, it is somehow 
more subtle. The one possibility would be, if there is an intrinsic 
property, which you have to find, indicating, that such an assignment will 
always fail. The other possibility is to add a boolean flag, which points 
out, if something went wrong. In the external assignment method you could 
set this flag appropriately and check it inside Drools.

Does this answer your question?
Alexander 




More information about the rules-users mailing list