Re: XQuery Update to return values

Carmelo Montanez <[email protected]> Fri, 27 Jul 2007 11:41:37 -0400
Newsgroups gmane.comp.web.query-languages
Message-ID <[email protected]>
--=====================_867989312==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

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
>
>
>
>

--=====================_867989312==.ALT
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by smtp.nist.gov id l6RFg8sV027795

<html>
<body>
Emma:<br><br>
If I am not mistaken, you can use a Transform expression, which will
return a value back.<br>
Something like this:<br><br>
let $var :=3D fn:doc(&quot;works-mod.xml&quot;)/works[1]/employee[1]<br>
let $var1 :=3D &lt;pnum&gt;P1-1&lt;/pnum&gt;<br>
return <br>
&nbsp;transform<br>
&nbsp; copy $newVar :=3D $var<br>
&nbsp; modify do replace $newVar/pnum[1] with $var1<br>
&nbsp; return $newVar<br><br>
Thanks,<br>
Carmelo<br><br>
<br>
At 02:02 PM 7/26/2007, Wu, Emma wrote:<br>
<blockquote type=3Dcite class=3Dcite cite=3D""><font size=3D2>Hi,<br>
&nbsp;<br>
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:<br>
&nbsp;<br>
1. update a book element=92s author <br>
2. return the updated book element<br>
&nbsp;<br>
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<br>
&nbsp;<br>
Thanks,<br>
Emma <br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
</font><font face=3D"Times New Roman, Times">&nbsp;</font></blockquote>
</body>
</html>

--=====================_867989312==.ALT--