This is true, but be aware that if a cell value in the Template data is empty the whole Fact Pattern is omitted.

For example:-

rule "Discount @{row.rowNumber}"
  when
    Account( $v : @{field} != null )
    $c : Customer( @{field} == $v , accno == @{accno} )
  then
    $c.setDiscount(1);
end

If "field" is empty neither "Account" or "Customer" will be included in the generated DRL.

If "accno" is empty "Customer" will not be included in the generated DRL.

This may have an impact on what you want to achieve.

With kind regards,

Mike

On 19 March 2012 21:29, Vincent LEGENDRE <vincent.legendre@eurodecision.com> wrote:
Hi

Instead of using a workaround, did you have a look to rule templates ?
 - under guvnor : http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1143
 - drl : http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e7501

You should be able to do exactly what you are trying to do, but properly, like that :

template header
field
accno

package range;

template "Discount"
 rule "Discount @{row.rowNumber}"
 when
   Account( $v : @{field} != null )
   $c : Customer( @{field} == $v , accno == @{accno} )
 then
   $c.setDiscount(1);
 end
end template


----- Mail original -----
De: "Sumeet Karawal" <sumeet.karawal@tcs.com>
À: "Rules Users List" <rules-users@lists.jboss.org>
Envoyé: Jeudi 15 Mars 2012 14:20:01
Objet: Re: [rules-users] Data comparing in CONDITION column decision table

I inserted Account column with values that are always true.

Works fine. :)

Will try the same with 5.3 .

Thanks & Regards,
Sumeet




 From:       Wolfgang Laun <wolfgang.laun@gmail.com>

 To:         Rules Users List <rules-users@lists.jboss.org>

 Date:       03/15/2012 05:30 PM

 Subject:    Re: [rules-users] Data comparing in CONDITION column decision table

 Sent by:    rules-users-bounces@lists.jboss.org






The documentation for 5.3.0 says
<quote>
To include a pattern without constraints, you can write the pattern in
front of the text for another pattern.
</quote>
but it does not work with 5.2.0 and (likely) later versions.

As a workaround, re-insert the Account column and use a redundant
condition that is certainly true for all facts.

I'll have to look into this.

-W


On 15/03/2012, Sumeet Karawal <sumeet.karawal@tcs.com> wrote:
> Hi Wolfgang
>
> any other way to achieve this. I have tried many times, but no success
till
> now :(
>
> Thanks,
> Sumeet
>
>
>
>
>   From:       Sumeet Karawal <sumeet.karawal@tcs.com>
>
>
>   To:         Rules Users List <rules-users@lists.jboss.org>
>
>
>   Date:       03/15/2012 04:24 PM
>
>
>   Subject:    Re: [rules-users] Data comparing in CONDITION column
decision
> table
>
>   Sent by:    rules-users-bounces@lists.jboss.org
>
>
>
>
>
>
>
>
>
> After doing the changes, its taking the rules as:
>
> rule "Discount_10"
>                                 when
>                                                                 $a:Account(type ==
$a.getType(), accno == 1001)
> $c:Customer
>                                 then
>                                                                 $c.setDiscount(1);
> end
>
>
> and if I put it as $a: Account() $c: Customer(), it takes the rules as:
>
> rule "Discount_10"
>                                 when
>                                                                 $a:Account(type ==
$a.getType(), accno == 1001)
> $c:Customer()
>                                 then
>                                                                 $c.setDiscount(1);
> end
>
> Both these throw error..
>
>
>
> neither putting the $c:Customer before $a:Account is getting executed.
>
>
> Thanks & Regards,
> Sumeet
> Mailto: sumeet.karawal@tcs.com
>
>
>
>   From:       Wolfgang Laun <wolfgang.laun@gmail.com>
>
>
>   To:         Rules Users List <rules-users@lists.jboss.org>
>
>
>   Date:       03/15/2012 04:06 PM
>
>
>   Subject:    Re: [rules-users] Data comparing in CONDITION column
decision
> table
>
>   Sent by:    rules-users-bounces@lists.jboss.org
>
>
>
>
>
>
>
> On 15/03/2012, Sumeet Karawal <sumeet.karawal@tcs.com> wrote:
>>
>> How to make changes to the decision table entries to get a drl of this
>> kind:
>>
>
> Put
>    $a: Account() $c: Customer
> into the cell where you now have $c : Customer and delete the Account
> column.
> -W
>
>>
>> rule "Discount_10"
>>                                                                 when
>>
                          $a : Account()
>>
                          $c : Customer(type ==
> $a.getType(), accno == 1001)
>>                                                                 then
>>
                          $c.setDiscount(1);
>> end
>>
>>
>> Thanks,
>> Sumeet
>> Mailto: sumeet.karawal@tcs.com
>>
>>
>>
>>   From:       Wolfgang Laun <wolfgang.laun@gmail.com>
>>
>>
>>   To:         Rules Users List <rules-users@lists.jboss.org>
>>
>>
>>   Date:       03/15/2012 02:47 PM
>>
>>
>>   Subject:    Re: [rules-users] Data comparing in CONDITION column
> decision
>> table
>>
>>   Sent by:    rules-users-bounces@lists.jboss.org
>>
>>
>>
>>
>>
>>
>>
>> Line breaks were lost in transit, but I think that you should remove
>> the quotes from
>>
>>    type == "$param"
>>
>> if you insert an expression $a.getType().
>>
>> -W
>>
>>
>> On 15/03/2012, Sumeet Karawal <sumeet.karawal@tcs.com> wrote:
>>>
>>> Hi,
>>>
>>> Can we use a data value of another object in the condition column of a
>>> Spreadsheet.
>>>
>>> For example: I have two data types(POJOs) one com.bank.Customer and
> other
>>> com.bank.Account
>>>
>>> in the rules I want to check whether the value entered for a particular
>>> field in Customer class is equal to the value entered for the
>> corresponding
>>> field in the Account class. eg Customer.accType = Account.accType()
>>>
>>>
>>> How can we achieve this using Decision table (CONDITION Column). I have
>>> tried this:
>>>
>>>             --------------------------------------------
>>>            |RuleTable
>>>            |Discount
>>>             --------------------------------------------
>>>            |CONDITION      |CONDITION                   |
>>>             ---------------+----------------------------|
>>>            |$a : Account   |$c : Customer               |
>>>             ---------------+----------------------------|
>>>            |               |type == "$param"
>>>  ----------+---------------+----------------------------
>>> | Discount |    Account    |            Type            |
>>> |  Rules   |               |                            |
>>> |----------+---------------+----------------------------|
>>> |    1     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>> |    2     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>> |    3     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>> |    4     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>> |    5     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>> |    6     |               |        $a.getType()        |
>>> |----------+---------------+----------------------------|
>>>
>>>
>>>
>>>
>>> But it won't work. It would be great if somebody could help me on this.
>>>
>>> Thanks & Regards,
>>> Sumeet Karawal
>>> Mailto: sumeet.karawal@tcs.com
>>>
>>> =====-----=====-----=====
>>> Notice: The information contained in this e-mail
>>> message and/or attachments to it may contain
>>> confidential or privileged information. If you are
>>> not the intended recipient, any dissemination, use,
>>> review, distribution, printing or copying of the
>>> information contained in this e-mail message
>>> and/or attachments to it are strictly prohibited. If
>>> you have received this communication in error,
>>> please notify us by reply e-mail or telephone and
>>> immediately and permanently delete the message
>>> and any attachments. Thank you
>>>
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users@lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users