2016-12-15 61 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中實現。在某些情況下,您需要彙總字段或計算字段以實現相同。

否則,您可以獲取結果集&您自己的代碼中的過濾/計算。