2016-12-15 60 views
1

我一直在努力将其转换为XML,有人可能会建议显示相同的信息,但这次用XML。从SQL转换为XML?

SQL低于

select so.ordernumber, 
     sod.productidname, 
     so.statuscode, 
     so.statuscodename, 
     sod.quantity, 
     sod.quantityshipped, 
     ip.pcssu_quantityavailable, 
     so.pcssu_stockavailable  
from FilteredSalesOrder so 
inner join FilteredSalesOrderDetail sod 
    on sod.salesorderid = so.salesorderid 
inner join filteredaccount a 
    on a.accountnumber = so.pcssu_servicecentrecode 
inner join Filteredpcssu_inventoryproduct ip 
    on ip.pcssu_product = sod.productid 
    and ip.pcssu_servicecenter = a.accountid 
where so.statuscode = '141560004' 
and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped 

我设法最上面到XML的转换只是没有和声明,转换器抛出错误了提

Error: Only conditions for the primary entity are supported in WHERE clause, consider moving the conditions for alias 'ip' to its JOIN's ON clause. Please note not all SQL queries can be converted to FetchXML due to the limitations of FetchXML query.

请告知也许移动和以接受和声明,抛出的错误是

where so.statuscode = '141560004' 
and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped 

下面是co nverted XML没有与

<fetch mapping="logical" version="1.0"> 
    <entity name="SalesOrder"> 
    <attribute name="ordernumber" /> 
    <attribute name="statuscode" /> 
    <attribute name="statuscodename" /> 
    <attribute name="pcssu_stockavailable" /> 
    <filter> 
     <condition attribute="statuscode" operator="eq" value="141560004" /> 
    </filter> 
    <link-entity name="SalesOrderDetail" from="salesorderid" to="salesorderid" alias="sod" link-type="inner"> 
     <attribute name="productidname" /> 
     <attribute name="quantity" /> 
     <attribute name="quantityshipped" /> 
     <link-entity name="pcssu_inventoryproduct" from="pcssu_product" to="productid" alias="ip" link-type="inner"> 
     <attribute name="pcssu_quantityavailable" /> 
     </link-entity> 
    </link-entity> 
    <link-entity name="account" from="accountnumber" to="pcssu_servicecentrecode" alias="a" link-type="inner" /> 
    </entity> 
</fetch> 
+1

你能举一个你想要输出看起来像什么的例子吗?另外,你说你在挣扎 - 这是否意味着你有一些尝试可以向我们展示?你是否想在SQL中或使用其他编程语言来做到这一点? – IMSoP

+0

[在FETCH XML中向WHERE子句添加AND语句?](https://stackoverflow.com/questions/41181726/add-and-statement-to-where-clause-in-fetch-xml) –

回答

0

有一个简单的XML输出作为mysql命令行工具的一部分 - 在这里看到的 - XML output from MySQL

命令行参数--xml - 但看起来就像这样<row><field name="id">1</field><field name="name">myname</field></row>

0
ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped 

基本上这种基于算术公式的过滤器不能在fetchxml中实现。在某些情况下,您需要汇总字段或计算字段以实现相同。

否则,您可以获取结果集&您自己的代码中的过滤/计算。