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.


#TechXchangePresenter
 View Only
  • 1.  Question about search distinct-value

    Posted Fri December 10, 2004 03:28 PM

    Hi
    I have a question about the following XQuery:
    declare namespace ft=“http://www.w3.org/2002/04/xquery-operators-text
    for $dbRecord in input()/Records/Record
    for $dbSet in $dbRecord/Sets/Set
    where
    $dbRecord/Year <= 1995
    and $dbRecord/Year >= 1995
    and $dbRecord/Sets/Set/Term = ‘First’
    and (ft:text-contains($dbSet/ProgramTitle, ‘testing’)
    or ft:text-contains($dbSet/SubjectTitle, ‘testing’)
    or ft:text-contains($dbSet/Department, ‘testing’))
    return $dbRecord
    sort by (Sets/Set[1]/SubjectCode, Year descending)

    if the a record have two set that match the where cause, it return the record twice, is it able to have distinct value of $dbRecord

    Thx!!


    #Tamino
    #API-Management
    #webMethods


  • 2.  RE: Question about search distinct-value

    Posted Tue December 14, 2004 06:15 PM

    Use the distinct-values() function.

    Regards,
    Guenter Grossberger
    Software AG


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: Question about search distinct-value

    Posted Thu December 16, 2004 02:28 AM

    Hi
    i have try the distinct-value for it do not allow me to use in the for statement i.e.
    for $dbRecord in distinct-values(input()/Records/Record) …

    The return is “Type exception: non-atomic type in element/attribute”

    Element/Attribute: Record; line 1, column 18:


    #Tamino
    #API-Management
    #webMethods


  • 4.  RE: Question about search distinct-value

    Posted Mon December 20, 2004 07:37 PM

    Have you experimented with using a LET instead of the FOR on $dbSet?

    Instead of:
    for $dbSet in $dbRecord/Sets/Set
    use:
    let $dbSet := $dbRecord/Sets/Set

    Douglas Kelly,
    Principal Consultant
    Software AG, Inc
    Sacramento, California


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: Question about search distinct-value

    Posted Tue December 21, 2004 09:18 AM

    Hi,

    If you do not want a ?Record? element being multiple times in you result set if it has multiple ?Set? elements fulfilling the ?where? clause you have to drop the second ?for? clause and add an existence check for ?Set? elements fulfilling the ?where? clause.
    An according query may look like this:


    for $dbRecord in input()/Records/Record
    let $x := for $dbSet in $dbRecord/Sets/Set
    where (ft:text-contains($dbSet/ProgramTitle, ‘testing’)
    or ft:text-contains($dbSet/SubjectTitle, ‘testing’)
    or ft:text-contains($dbSet/Department, ‘testing’))
    return $dbSet
    where
    $x
    and $dbRecord/Year <= 1995
    and $dbRecord/Year >= 1995
    and $dbRecord/Sets/Set/Term = ‘First’
    return $dbRecord
    sort by (Sets/Set[1]/SubjectCode, Year descending)

    The idea of the query is to collect for each ?Record? element all ?Set? elements in $x and performing a non empty check on $x. Since $x is bound to a node sequence you can do this by just adding $x to the ?where? clause.

    Best regards,

    Thorsten Fiebig


    #Tamino
    #API-Management
    #webMethods