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.  No Groupby in XQuery is a pain!!

    Posted Mon June 14, 2004 06:14 AM

    Hello Everyone,

    I am sitting here since three hours trying to figure out how to make a simple group by in XQuery. I really don’t understand why W3C decided not implementing an Groupby into XQuery.

    My Sql Statement:

    SELECT
    wisc_berkeley_tracetime.rID,
    wisc_berkeley_tracelist.ip	
    
    FROM
    wisc_berkeley_tracelist INNER JOIN wisc_berkeley_tracetime 		
    ON wisc_berkeley_tracelist.rID= wisc_berkeley_tracetime.rID
    WHERE
    (wisc_berkeley_tracetime.dat = '20000801000000')
    GROUP by wisc_berkeley_tracelist.ip;
    </pre><BR><BR>So this is the exact statement in XQuery just without Group by:<BR><BR><pre class="ip-ubbcode-code-pre">
    for $tl in doc("wisc_berkeley_tracelist.xml")/data/row
    for $tt in doc("wisc_berkeley_tracetime.xml")/data/row[dat='20000801000000' and rID=$tl/rID]
    
    return 
    <ROW>
    
    {	$tl/ip  } 
    {	$tt/rID  } 
    
    </ROW>




    But how do I the Group by?

    Best Regards

    Houman Khorasani
    University of Wisconsin Platteville


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: No Groupby in XQuery is a pain!!

    Posted Mon June 14, 2004 11:26 AM

    Hi,

    XQuery supports grouping with the aid of the distinct-values()
    function that is not yet supported with Tamino 4.1. It will
    however be contained in 4.2. On how to do grouping with
    distinct-values() please check appendix G2 in the W3C’s XQuery
    draft, i.e. http://www.w3.org/TR/xquery/#id-grouping.

    Regards,
    Juliane.


    #webMethods
    #Tamino
    #API-Management


  • 3.  RE: No Groupby in XQuery is a pain!!

    Posted Tue June 15, 2004 11:41 PM

    Hi Juliane,

    It’s ok I am trying it with Saxon.

    Actually it really gets hard if I need to groupby within a join.

    The xample in W3 Draft doesn’t explain groupby within a join.

    SELECT
    wisc_berkeley_tracetime.rID,
    ip,
    min
    FROM
    wisc_berkeley_tracelist INNER JOIN wisc_berkeley_tracetime           
    ON wisc_berkeley_tracelist.rID = wisc_berkeley_tracetime.rID
    WHERE
    (wisc_berkeley_tracetime.ndate = '20000801000000')
    GROUP by wisc_berkeley_tracelist.ip;
    </pre><BR><BR>This XQuery statement has no ?group by? on ip yet.  I am aware of distinct-value but have no idea how to use it in an efficient way on this query.<BR> <BR><pre class="ip-ubbcode-code-pre">
    for $wbtl in doc("wisc_berkeley_tracelist.xml")//row,
    $wbtt in doc("wisc_berkeley_tracetime.xml")//row[dat = '20000801000000' and rID = $wbtl/rID]
    return 
    <ROW>
    { 
    $wbtt/rID, $wbtl/ip, $wbtt/min
    } 
    </ROW>



    Do you have an idea how to do that?

    Thanks

    Houman Khorasani
    University of Wisconsin Platteville


    #webMethods
    #API-Management
    #Tamino


  • 4.  RE: No Groupby in XQuery is a pain!!

    Posted Wed July 14, 2004 03:24 PM

    Hi,

    let $wbttlist :=
    for $wbtl in doc(“wisc_berkeley_tracelist.xml”)//row
    return doc(“wisc_berkeley_tracetime.xml”)//row[dat = ‘20000801000000’ and rID = $wbtl/rID]
    for $ip in distinct-values($wbttlist/ip)
    return

    {
    for $wbtt in $wbbtlist[ip = $ip]
    return

    {
    $wbtt/rID, $wbtt/min
    }

    }


    Regards,
    Juliane.


    #Tamino
    #API-Management
    #webMethods