How to escape special characters while using like clause in table/sql constructs in rulebase?

How to escape special characters while using like clause in table/sql constructs in rulebase?

book

Article ID: KB0091554

calendar_today

Updated On:

Products Versions
TIBCO Collaborative Information Manager -
Not Applicable -

Description

Resolution:
Description:
============
With the out-of-the-box rulebase constructs it is not possible to escape special characters such as  '_' while using a like clause. Say for example, if the like clause uses '%A_B%' the '_' would not be taken as a literal. If the column against which like clause is subjected has the following values, A_B, ABC, both A_B and ABC would be returned when ABC is not an expected result.

Environment:
===========
TIBCO Collaborative Information manager (CIM) 8.X.X.


Cause:
=====
The out-of-the-box constructs in rulebase do not provide a way to escape special characters.

Resolution:
==========
The following approach can be used as a workaround. Notice the ‘where’ clause usage. With this approach the ‘_’ character would be escaped and only records having A_B would be returned.

&ltdeclare>
    &ltvar&gtLIKES</var>
    &ltlink type="catalog">
    &ltliteral&gtLIKES</literal>
    </link>
</declare>

&ltconstraint>
        &ltname&gtDropDown</name>
        &ltdescription&gtDropDown</description>
        &ltusefor>
            &ltvar&gtATTR1</var>
        </usefor>
        &ltaction>
            &ltselect novalue="default">
                &lttable distinct="false" source="sql">
                    &ltliteral&gtLIKES/ATTR1</literal>
                    &ltwhere type="sql">
                        &ltconst type="string"&gtLIKES.CATTR1 LIKE '%A/_B%' escape '/'</const>
                    </where>
                </table>
            </select>
        </action>
</constraint>
</rulebase>

Attachments:
===========
None.

References:
==========
None.

Issue/Introduction

How to escape special characters while using like clause in table/sql constructs in rulebase?