webMethods

webMethods

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

Updating after using FLWOR queries

  • 1.  Updating after using FLWOR queries

    Posted Wed September 21, 2005 05:42 PM

    Hi

    I’ve written a simple VB.NET app which pulls data from a Tamino db into a datagrid for update. The data appears fine, and is updateable without problems when the query I use to initially retrieve the data is along the lines of “input()/ enquiry” (ie it just relates to a document). However, the structure I want to edit is fairly complex and I want to shield the user from having to navigate through it, so I’ve created a FLWOR expression as follows:

    for $b in input()/enquiry
    where $b/enquiry-no=‘204122’
    return { $b/enquiry-no,
    $b/service-data/description,
    $b/customer-data/forename,
    $b/customer-data/surname,
    $b/customer-data/paon,
    $b/customer-data/street-name,
    $b/customer-data/locality,
    $b/customer-data/town,
    $b/customer-data/postcode,
    $b/status,
    $b/comments }

    The data is retrieved as desired, but when I make a change to the data and attempt an ‘update’ against my TaminoDataAdapter object, it just hangs until the timeout catches it.

    Can I use a FLWOR expression as above in an updateable dataset? If so, then can you give me some ideas as to why this isn’t working? I’ve read about the mapping that’s sometimes required for updating subtrees - do I need these setting?

    Thanks in advance. Rgds


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: Updating after using FLWOR queries

    Posted Wed September 21, 2005 06:52 PM

    As there is no tie between the documents and the original Tamino documents, you can’t update Tamino documents directly from this type of query.


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 3.  RE: Updating after using FLWOR queries

    Posted Wed September 21, 2005 07:06 PM

    Thanks for the prompt reply. It’s not what I wanted to hear, but I can understand why it won’t work (I just hoped the API would be able to work it out!). The structure of the XML is too unwieldy for our end-users to navigate as it stands, so I need to find a way to simplify it - I’d appreciate anyone’s views on how this might best be done.

    My current thoughts are along the lines of using the .NET API to extract the data in the form I want (ie. using FLWOR), but then sending the user-updated XML stream back via a webservice which is forwarded to a Mediator sequence which can extract the data and insert it into the correct positions in the database. Does this sound feasible? Anyone any other ideas of how I could still achieve this using the .NET API?

    Rgds, Matt.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 4.  RE: Updating after using FLWOR queries

    Posted Wed September 21, 2005 07:31 PM

    My thought would be to include the ino:id (or application unique id for the documents) in the set for the documents. When the update is requested, obtain each modified document via the ino:id/uqid from the dataset and use the Update command or a FLWU update XQUERY to modify the documents.


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 5.  RE: Updating after using FLWOR queries

    Posted Thu September 22, 2005 10:40 AM

    Thanks for the reply. I’m a relative newcomer to XML so may need some hand-holding through this one, but I’ll give it a go as per your suggestion. Thanks for your help so far - very much appreciated. Rgds, Matt.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 6.  RE: Updating after using FLWOR queries

    Posted Fri September 23, 2005 08:28 AM

    I think that the TaminoDataAdapter was intended to allow the user to query subtrees, manipulate them + update them. You’ll need to help identify the subtrees for updating.

    Have look under the DataSetSamples QueryItemMapping.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 7.  RE: Updating after using FLWOR queries

    Posted Tue September 27, 2005 04:35 PM

    Hi. I’m progressing slowly on this, but now have the data being returned to a datagrid in VB.NET, and am now at the point where I want to push updates back into Tamino. I have a unique attribute to search on (the ‘enquiry-no’), and have constucted the following XQuery as a test in the interactive interface (to help me understand updating data in Tamino)

    update for $b in input()/enquiry
    where $b/enquiry-no=‘204148’
    do replace $b/comments
    with attribute comments {‘MJB Test’}

    However, when I run this I get a message stating “It is not possible to open a cursor with XQuery Update Request.”. Anyone have any idea why?


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 8.  RE: Updating after using FLWOR queries

    Posted Tue September 27, 2005 07:29 PM

    is “comments” an attribute or not? You are asking to replace an element ($b/comments) with an attribute “with attribute comments…”.


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 9.  RE: Updating after using FLWOR queries

    Posted Wed September 28, 2005 09:30 AM

    Hi,

    I assume you try this from Tamino Interactive Interface. The problem is that you cannot open a cursor with update statements (they do not give back any documents). Tamino Interactive Interface tries to open a cursor, however, if the “pos” field is checked

    Hope this helps

    Regards

    Harald


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 10.  RE: Updating after using FLWOR queries

    Posted Wed September 28, 2005 12:52 PM

    Douglas, Harald- Thanks both for your responses; you were each correct and I’ve now got my updates working from the Interactive Interface as a result. I just need to try and transpose this into Visual Studio now… don’t go too far away…

    Thanks.


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 11.  RE: Updating after using FLWOR queries

    Posted Wed September 28, 2005 04:33 PM

    One last thing: I’ve written the following:

    update for $b in input()/enquiry
    where $b/enquiry-no=‘204149’
    do replace $b/comments
    with element comments {‘MJB Test’}

    which works fine. However, how would I update two elements at the same time (eg. element name ‘status’)? I’ve tried:

    update for $b in input()/enquiry
    where $b/enquiry-no=‘204149’
    do replace $b/comments
    with element comments {‘MJB Test’}, status{‘Closed’}

    but it fails with a syntax error. Could someone tell me what the correct syntax for this would be?


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 12.  RE: Updating after using FLWOR queries

    Posted Wed September 28, 2005 07:37 PM

    update for $b in input()/enquiry
    where $b/enquiry-no=‘204149’
    do (
    replace $b/comments with element comments {‘MJB Test’}
    replace $b/status with element status{‘Closed’}
    )


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 13.  RE: Updating after using FLWOR queries

    Posted Thu September 29, 2005 02:46 PM

    Thanks for that Douglas; works a treat. That’s me finished on this work for now - I’ve got a working prototype to put to the business for their comment. Thanks for all your help.


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods


  • 14.  RE: Updating after using FLWOR queries

    Posted Thu September 29, 2005 05:53 PM

    Back already I’m afraid… I’ve got an element in my XML which reads:

    When I use a FLWOR query to extract this (albeit blank) value, eg.

    for $b in input()/enquiry
    where $b/queue-description = ‘xxxx’
    return {$b/ContractorCommentsTextarea}

    I get:

    As expected, it returns an empty value, but it also returns the ‘description’ (attribute?) and its value. Unfortunately, the dataGrid control in .NET interprets this as a new table and my wonderful app falls apart.

    Is there a syntax for just extracting the value of the element without the ‘description’ attribute (if ‘attribute’ is the correct term for this)? I’d like to get the following in my output:

    (or myText for when there’s a value to return).

    I’ll really stop bothering you soon… :slight_smile:


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 15.  RE: Updating after using FLWOR queries

    Posted Fri September 30, 2005 09:34 AM

    If oyu extract an element, you get the value and all attributes, that is what happened to you. In order to get just the value, you can extract the value only and add the element tags by yourself, as in the following query:
    for $b in input()/enquiry
    where $b/queue-description = ‘xxxx’
    return {$b/ContractorCommentsTextarea/text()}

    Regards

    Harald


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 16.  RE: Updating after using FLWOR queries

    Posted Fri September 30, 2005 10:52 AM

    The /text() function works fine, but how do I create the element tags? I’ve tried the following:

    … return {“comments”,$b/enquiry-data/ContractorCommentsTextarea/text(),“”}

    and although I get the correct format out, my browser (and my app’s dataset) don’t recognise this as an element; they ‘know’ it’s a fake! Is there a way to define this text so it appears as an element name/tag?


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 17.  RE: Updating after using FLWOR queries

    Posted Fri September 30, 2005 11:00 AM

    By sheer chance I’ve managed to find the solution:

    {$b/enquiry-data/ContractorCommentsTextarea/text()}

    Thanks for your help. Rgds.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 18.  RE: Updating after using FLWOR queries

    Posted Fri September 30, 2005 01:08 PM

    There are constructors in XQuery, which use teh same syntax as in XML:

    return example value

    There is an alternative form:

    return element mynewElement {“example value”}


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs