I was struggling to convert this to XML, could someone please advise to display same information but this time in XML.
SQL is below
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
I managed to convert most of the above to XML just without the and statement, the converter threw an error up mentioning
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.
Please advise perhaps moving the and to joing the and statement thats throwing the error is
where so.statuscode = '141560004'
and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped
Below is converted XML without AND
<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>