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
Expand all | Collapse all

Query to select last Node in Result set

webMethods Community Member

webMethods Community MemberWed January 09, 2002 06:41 PM

  • 1.  Query to select last Node in Result set

    Posted Mon January 07, 2002 04:38 PM

    I am trying to figure out how to select the last node in a result set from Tamino. I can’t figure this out, I have tried doing the following query:

    http://mercury/tamino/plumbingpermits/plm/govmedoc?_xql=/govmedoc/PermitDetails/CaseNumber[last()]

    This query works, but it returns every document in the result set. I only want the last document so I can get the last CaseNumber to generate a new CaseNumber.

    Thanks for your answers!
    Knute Hestness
    City of Tacoma


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: Query to select last Node in Result set



  • 3.  RE: Query to select last Node in Result set

    Posted Tue January 08, 2002 12:27 AM

    Alexander,
    Thanks for your response, I tried the query and it returns the very first document in my collection, any other ideas?

    Here is the resultset:
    ------------------------------------------------
    xql:query/govmedoc/PermitDetails/CaseNumber sortby (. desc)</xql:query>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processing</ino:messageline>
    </ino:message>
    - xql:result
    PLM2000-00001
    </xql:result>
    - <ino:cursor ino:count=“4383”>
    <ino:first ino:href=“?_XQL(1,1)=/govmedoc/PermitDetails/CaseNumber sortby (. desc)” />
    <ino:next ino:href=“?_XQL(2,1)=/govmedoc/PermitDetails/CaseNumber sortby (. desc)” />
    <ino:last ino:href=“?_XQL(4383,1)=/govmedoc/PermitDetails/CaseNumber sortby (. desc)” />
    </ino:cursor>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processed</ino:messageline>
    </ino:message>
    </ino:response>
    -------------------------------------------------
    Knute Hestness


    #Tamino
    #API-Management
    #webMethods


  • 4.  RE: Query to select last Node in Result set

    Posted Tue January 08, 2002 08:19 AM

    Currently the query returns sorted (descending) CaseNumber Nodes per document, in the natural Document order. This returns the highest valued CaseNumber Node from the first document, which is not what you want.

    You need to sort the documents into descending CaseNumber order before extracting the CaseNumber node from the last document. So you could try:

    http://mercury/tamino/plumbingpermits/plm/govmedoc?_xql(1,1)=/govmedoc sortby(PermitDetails/CaseNumber desc)/PermitDetails/CaseNumber


    #API-Management
    #webMethods
    #Tamino


  • 5.  RE: Query to select last Node in Result set

    Posted Tue January 08, 2002 12:32 PM

    Yeah, true
    mistaken a little
    and do not forget standard index for CaseNumber node


    #webMethods
    #API-Management
    #Tamino


  • 6.  RE: Query to select last Node in Result set

    Posted Tue January 08, 2002 11:46 PM

    I have tried the current query and it still gives me the 1 record out of 4383. It seems like such a simple request, find the last node in the collection.

    Here is the result set from the latest query:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <ino:response xmlns:ino=“http://namespaces.softwareag.com/tamino/response2” xmlns:xql=“XQL FAQ (XML Query Language - Frequently Asked Questions)”>
    xql:query/govmedoc sortby(PermitDetails/CaseNumber desc)/PermitDetails/CaseNumber</xql:query>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processing</ino:messageline>
    </ino:message>
    - xql:result
    PLM2000-00001
    </xql:result>
    - <ino:cursor ino:count=“4383”>
    <ino:first ino:href=“?_XQL(1,1)=/govmedoc sortby(PermitDetails/CaseNumber desc)/PermitDetails/CaseNumber” />
    <ino:next ino:href=“?_XQL(2,1)=/govmedoc sortby(PermitDetails/CaseNumber desc)/PermitDetails/CaseNumber” />
    <ino:last ino:href=“?_XQL(4383,1)=/govmedoc sortby(PermitDetails/CaseNumber desc)/PermitDetails/CaseNumber” />
    </ino:cursor>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processed</ino:messageline>
    </ino:message>
    </ino:response>

    Knute Hestness


    #Tamino
    #webMethods
    #API-Management


  • 7.  RE: Query to select last Node in Result set

    Posted Wed January 09, 2002 09:32 AM

    This would suggest that sortby isn’t sorting the records. Can you please confirm this by running the query…

    http://mercury/tamino/plumbingpermits/plm/govmedoc?_xql=/govmedoc sortby(PermitDetails/CaseNumber desc)

    …and look at the CaseNumber value in each returned document. If these values are not in the expected sequence, can you please post your schema and a couple of your xml documents to the forum. Thanks.


    #API-Management
    #webMethods
    #Tamino


  • 8.  RE: Query to select last Node in Result set

    Posted Wed January 09, 2002 06:41 PM

    Here is the DTD that the Schema is based on:


    ------------------ Sample Document from Tamino:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <ino:response xmlns:ino=“http://namespaces.softwareag.com/tamino/response2” xmlns:xql=“XQL FAQ (XML Query Language - Frequently Asked Questions)”>
    xql:query/govmedoc[@ino:id=‘5’]</xql:query>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processing</ino:messageline>
    </ino:message>
    - xql:result
    -
    -
    5


    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL

    -
    3245000440
    NULL
    -
    3219


    N
    8TH
    ST

    NULL
    NULL
    PIERCE
    TACOMA


    -
    PLM2000-00006

    PLM2000-00006
    NULL
    1/4/00
    1/4/00
    3/27/00
    A
    First Dump
    REP




    NULL

    1
    NULL

    NULL


    NULL
    NULL
    NULL
    NULL




    </xql:result>
    - <ino:message ino:returnvalue=“0”>
    ino:messagelineXQL Request processed</ino:messageline>
    </ino:message>
    </ino:response>


    #webMethods
    #Tamino
    #API-Management


  • 9.  RE: Query to select last Node in Result set

    Posted Thu January 10, 2002 09:31 AM

    The DTD doesn’t really help. Can you please post your Tamino Schema (Use the Schema Editor; Database, Get Schema… and File, Save As …).
    Thanks.


    #API-Management
    #webMethods
    #Tamino


  • 10.  RE: Query to select last Node in Result set

    Posted Thu January 10, 2002 04:37 PM

    Here is the Schema you requested, thanks for your help.
    theSchema.xml (12.4 KB)


    #webMethods
    #API-Management
    #Tamino


  • 11.  RE: Query to select last Node in Result set

    Posted Thu January 10, 2002 04:45 PM

    Thanks for the schema. The node you are trying to sort by does not have a standard index, so sort will not work (see Alexander’s second post above).

    Here is a modified schema that should work.
    theSchema_modified.xml (12.4 KB)


    #API-Management
    #Tamino
    #webMethods


  • 12.  RE: Query to select last Node in Result set

    Posted Fri January 11, 2002 05:42 PM

    Thanks for your help, I now have Amit Mangal from Software AG who is helping me with this problem. We are redesigning the schema and breaking out the nodes to seperate doc types and then linking them with GUID’s.


    Knute Hestness
    City of Tacoma


    #Tamino
    #API-Management
    #webMethods