Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL update语句转换为XQuery_Sql_Sql Update_Xquery - Fatal编程技术网

SQL update语句转换为XQuery

SQL update语句转换为XQuery,sql,sql-update,xquery,Sql,Sql Update,Xquery,因此,如上所述,在将更新sql查询转换为xquery时,我的更新示例如下所示 UPDATE Products SET [List Price] = 19 WHERE [ID]= 1; 在需要的地方,只要假设一个变量,我就知道XQuery是如何工作的,如果这是唯一的方法,那么路径只是使用随机示例。我只是找不到一个好的例子来解释如何以同样的方式更新 <Products> <Supplier_x0020_IDs> <Value>4</Value> &l

因此,如上所述,在将更新sql查询转换为xquery时,我的更新示例如下所示

UPDATE Products
SET [List Price] = 19
WHERE [ID]= 1;
在需要的地方,只要假设一个变量,我就知道XQuery是如何工作的,如果这是唯一的方法,那么路径只是使用随机示例。我只是找不到一个好的例子来解释如何以同样的方式更新

<Products>
<Supplier_x0020_IDs>
<Value>4</Value>
</Supplier_x0020_IDs>
<ID>1</ID>
<Product_x0020_Code>NWTB-1</Product_x0020_Code>
<Product_x0020_Name>Northwind Traders Chai</Product_x0020_Name>
<Standard_x0020_Cost>13.5</Standard_x0020_Cost>
<List_x0020_Price>18</List_x0020_Price>
<Reorder_x0020_Level>10</Reorder_x0020_Level>
<Target_x0020_Level>40</Target_x0020_Level>
<Quantity_x0020_Per_x0020_Unit>10 boxes x 20 bags</Quantity_x0020_Per_x0020_Unit>
<Discontinued>0</Discontinued>
<Minimum_x0020_Reorder_x0020_Quantity>10</Minimum_x0020_Reorder_x0020_Quantity>
<Category>Beverages</Category>
</Products>

4.
1.
NWTB-1
柴北风贸易商
13.5
18
10
40
10盒20袋
0
10
饮料

这就是XML的样子,它非常混乱,因此我避免发布它,但现在它又被卡住了。如果您想在XQuery中进行更新,那么您需要使用它,这实际上取决于您的实现是否支持它

由于您没有告诉我们您的XML是什么样子,我将假设如下:

<Products>
  <Product>
    <ID>1</ID>
    <ListPrice>20</ListPrice>
  </Product>
  <Product>
    <ID>2</ID>
    <ListPrice>7</ListPrice>
  </Product>
</Products>

注意,我假设您的XQuery处理器不知道模式,也不知道节点的类型,所以我一直假设字符串。此外,我还从“标价”中删除了空格,因为XML元素的名称中不能包含空格。

谢谢您的回答,但我可能无法从中找到答案,谢谢:)@bilbsy也许如果您告诉我们更多信息,那么我们可以进一步提供帮助。我添加了XML的格式,但不确定还能提供什么其他信息(理解它很凌乱,但它不是我的xml文档)而且x0020只是用于间隔…也很烦人
replace value of node /Products/Product[ID eq "1"]/ListPrice with "19"