【发布时间】:2017-05-01 02:12:20
【问题描述】:
我正在努力将其转换为 XML,有人可以建议显示相同的信息,但这次是在 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
我设法在没有 and 语句的情况下将上述大部分内容转换为 XML,转换器在提及时抛出了一个错误
错误:WHERE 子句仅支持主要实体的条件,请考虑将别名“ip”的条件移至其 JOIN 的 ON 子句。 请注意,由于 FetchXML 查询的限制,并非所有 SQL 查询都可以转换为 FetchXML。
请建议移动 and 加入 and 抛出错误的语句是
where so.statuscode = '141560004'
and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped
下面是没有AND的转换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>
【问题讨论】:
-
您能否举例说明您希望输出的外观?另外,你说你在挣扎——这是否意味着你可以向我们展示一些尝试?您是尝试在 SQL 中执行此操作,还是使用其他编程语言?
标签: sql dynamics-crm fetchxml