IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  who to make where clause case insensitive

    Posted Tue June 19, 2007 08:04 PM

    Hello again,

    Is there a way to make an expression in a where clause case insensitive? I currently have this where clause:

    where $settings/@UserId='Johnny'

    Unfortunately, the case of the UserId attribute is unpredicatble. Is there an Xquery expression operator I can use to make this case insensitive?

    Thanks,
    Allen


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: who to make where clause case insensitive

    Posted Wed June 20, 2007 01:39 AM

    You can use tf:contains-text($settings/@UserId,“John”). However, this would match on “John”, “Johnson” and “Johnny”, so the lower-case (or upper-case) function might work better:

    where lower-case($settings/@UserID) = lower-case("Johnny")

    See the documentation “XQuery Reference Guide” for more functions and details.


    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: who to make where clause case insensitive

    Posted Wed June 20, 2007 02:15 AM

    A good pragmatic approach. For the purists:

    you can influence Tamino’s behaviour also by specifying a collation, e.g. in the prologue of an XQuery:

    declare default collation “collation?language=…”

    or in the comparison
    where compare($settings/@UserId, ‘Johnny’, “collation?..”) = 0

    where you can also specify to ignore case


    #Tamino
    #API-Management
    #webMethods


  • 4.  RE: who to make where clause case insensitive

    Posted Wed June 20, 2007 04:22 AM

    This is a 4.2.1 database so using the lower-case() function did not work. I did not see this function described in the 4.2.1 documentation.

    I tried the following which did not work either:

    where compare($settings/@UserId,'Johnny','collation?caseLevel=true') = 0

    Any ideas why the above did not work? I did not really understand the documentation on caseLevel and I’m not sure it’s really what I need to use.

    Thanks,
    Allen


    #Tamino
    #API-Management
    #webMethods


  • 5.  RE: who to make where clause case insensitive

    Posted Wed June 20, 2007 02:18 PM

    In 4.2, you can use:
    declare default collation “collation?strength=secondary”;
    “X” = “x”

    or

    compare(“X”, “x”, “collation?strength=secondary”)

    But it might be a good idea to upgrade to 4.4!

    Regards

    Harald


    #webMethods
    #Tamino
    #API-Management


  • 6.  RE: who to make where clause case insensitive

    Posted Thu June 21, 2007 01:48 AM

    ok, well I have to agree with Alan’s problem…I wouldn’t have found this to perform a case-insensitive search either. Even after reading it through, I’d be hard-pressed to know that was what this collation?strength was for.

    Be that as may, I’m not sure if I’ve understood the suggestion - if I try the two forms on my Tamino 4.4 database, I get completely different results:

    declare default collation "collation?strength=secondary"
    for $r in input()/Role
    where $r/@RoleName = "purchasing agent"
    return $r

    retrieves the expected single document

    <Role MDR_JobFunction="002" RoleID="1" RoleName="Purchasing Agent"/>

    but

    for $r in input()/Role
    where compare($r/@RoleName, "purchasing agent","collation?strength=secondary")
    return $r

    retrieves a set of documents that don’t match my selection, such as

    <Role MDR_JobFunction="205" RoleID="2" RoleName="Middle/Junior High Princi"/>
    <Role MDR_JobFunction="301" RoleID="3" RoleName="Math Dept Chairperson"/>
    <Role MDR_JobFunction="321" RoleID="4" RoleName="Science Dept Chairperson"/>

    am I using the compare function in the second example incorrectly?


    #Tamino
    #API-Management
    #webMethods


  • 7.  RE: who to make where clause case insensitive

    Posted Thu June 21, 2007 12:24 PM

    Sorry, I was too short. The compare function returns an integer (0 if the values are equal). So in the form you used it, you selected all elements where the value was non-0 (and these are the elements you did not want to see :frowning: ). If you change to

    
    for $r in input()/Role
    where compare($r/@RoleName, "purchasing agent","collation?strength=secondary")=0
    return $r

    you should get the expected result.

    Regards

    Harald


    #webMethods
    #Tamino
    #API-Management


  • 8.  RE: who to make where clause case insensitive

    Posted Tue July 17, 2007 11:38 PM

    It took me a while to get back to this but I wanted to let everyone know that Dr. Sch


    #Tamino
    #API-Management
    #webMethods