|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
XQuery Update to return valuesHi, The problem I am trying to solve is that with XQuery Update
faicility, I will update an element and at the same time, I want the same
element to be returned. Something like the following: 1. update a book element’s author 2. return the updated book element Is there a way to do it in one query instead of two separate
queries? And it looks like update expression does not return anything Thanks, Emma |
|
|
Re: XQuery Update to return values
Emma:
If I am not mistaken, you can use a Transform expression, which will return a value back. Something like this: let $var := fn:doc("works-mod.xml")/works[1]/employee[1] let $var1 := <pnum>P1-1</pnum> return transform copy $newVar := $var modify do replace $newVar/pnum[1] with $var1 return $newVar Thanks, Carmelo At 02:02 PM 7/26/2007, Wu, Emma wrote: Hi, |
|
|
RE: XQuery Update to return valuesThe query below does not change the original document. Only the copied var $newVar is updated. I need the $var to be updated and return the updated $var as well. Any idea? Thanks. Emma -----Original Message----- From: Carmelo Montanez [mailto:carmelo@...] Sent: Fri 7/27/2007 9:41 AM To: Wu, Emma; www-ql@... Subject: Re: XQuery Update to return values Emma: If I am not mistaken, you can use a Transform expression, which will return a value back. Something like this: let $var := fn:doc("works-mod.xml")/works[1]/employee[1] let $var1 := <pnum>P1-1</pnum> return transform copy $newVar := $var modify do replace $newVar/pnum[1] with $var1 return $newVar Thanks, Carmelo At 02:02 PM 7/26/2007, Wu, Emma wrote: >Hi, > >The problem I am trying to solve is that with XQuery Update >faicility, I will update an element and at the same time, I want the >same element to be returned. Something like the following: > >1. update a book element's author >2. return the updated book element > >Is there a way to do it in one query instead of two separate >queries? And it looks like update expression does not return anything > >Thanks, >Emma > > > > |
|
|
Re: XQuery Update to return valuesHi Emma, In the current spec, you can either change a data model instance with a query that generates a pending update list, or do a transform or a query, but you can't do both. And all expressions in an update are evaluated within one snapshot. The Scripting Extensions for XQuery will introduce statements, allowing expressions to be evaluated after an update has been made. Only the requirements document currently exists: http://www.w3.org/TR/xquery-sx-10-requirements/ In the meantime, you can do this if you embed XQuery in a procedural language. Hope this helps! Jonathan Wu, Emma wrote: > The query below does not change the original document. Only the copied var $newVar is updated. > I need the $var to be updated and return the updated $var as well. Any idea? Thanks. > > Emma > > > -----Original Message----- > From: Carmelo Montanez [mailto:carmelo@...] > Sent: Fri 7/27/2007 9:41 AM > To: Wu, Emma; www-ql@... > Subject: Re: XQuery Update to return values > > Emma: > > If I am not mistaken, you can use a Transform expression, which will > return a value back. > Something like this: > > let $var := fn:doc("works-mod.xml")/works[1]/employee[1] > let $var1 := <pnum>P1-1</pnum> > return > transform > copy $newVar := $var > modify do replace $newVar/pnum[1] with $var1 > return $newVar > > Thanks, > Carmelo > > > At 02:02 PM 7/26/2007, Wu, Emma wrote: > >> Hi, >> >> The problem I am trying to solve is that with XQuery Update >> faicility, I will update an element and at the same time, I want the >> same element to be returned. Something like the following: >> >> 1. update a book element's author >> 2. return the updated book element >> >> Is there a way to do it in one query instead of two separate >> queries? And it looks like update expression does not return anything >> >> Thanks, >> Emma >> >> >> >> >> > > > > |
|
|
|
|
|
RE: XQuery Update to return valuesCan not do this in the current version of
the update facility. This use case was accepted to be resolved
as part of the Scripting Extension facility work – part 3.4 of the requirements:
http://www.w3.org/TR/xquery-sx-10-requirements/#functionalities
– returning values from expressions that have side-effects. Daniel; From:
www-ql-request@... [mailto:www-ql-request@...] On Behalf Of Wu, Emma Hi, The problem I am trying to solve is that with XQuery Update faicility,
I will update an element and at the same time, I want the same element to be
returned. Something like the following: 1. update a book element’s author 2. return the updated book element Is there a way to do it in one query instead of two separate
queries? And it looks like update expression does not return anything Thanks, Emma Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. |
|
|
Re: XQuery Update to return valuesHi Emma, > What is the syntax that X-Hive/DB supports for returning values? Or > are > there any documents I can have a look at? Thanks. X-Hive simply allows to mix updating statements with non-updating statements, i.e. declare updating function local:foo() as xs:integer { let $items := ... return ( do delete $items, count($items)) } You can download X-Hive/DB from http://www.x-hive.com/products/db/, the download includes documentation. Regards, Martin -- Martin Probst X-Hive Corporation martin@... |
|
|
RE: XQuery Update to return values>X-Hive simply allows to mix updating statements with non-updating >statements, i.e. It's nice not having to worry about any other possible implementations. :) D; Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. |
|
|
Re: XQuery Update to return values>> X-Hive simply allows to mix updating statements with non-updating >> statements, i.e. > > It's nice not having to worry about any other possible > implementations. > :) Well, I've always adhered to anything in the standard, so I really had a bad feeling about this. Still, I think it should be possible to do such easy things as getting the number of items deleted without resorting to some scripting language etc. Also, I'm not sure how it turns out, but if the single steps in an XQuery "script" really run transactionally separated, getting this information might still be problematic... Martin -- Martin Probst X-Hive Corporation martin@... |
| Free embeddable forum powered by Nabble | Forum Help |