Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.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转换为XML?_Sql_Dynamics Crm_Fetchxml - Fatal编程技术网

从SQL转换为XML?

从SQL转换为XML?,sql,dynamics-crm,fetchxml,Sql,Dynamics Crm,Fetchxml,我正在努力将其转换为XML,请有人建议显示相同的信息,但这次是XML SQL在下面 select so.ordernumber, sod.productidname, so.statuscode, so.statuscodename, sod.quantity, sod.quantityshipped, ip.pcssu_quantityavailable, so.pcssu_stoc

我正在努力将其转换为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”的条件移到其联接的ON子句。 请注意,由于FetchXML查询的限制,并非所有SQL查询都可以转换为FetchXML

请建议可能移动and以连接引发错误的and语句

where so.statuscode = '141560004'
and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped
下面是不带和的转换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>

作为
mysql
命令行工具的一部分,有一个简单的xml输出-请参见此处-


命令行参数
--xml
-但是输出看起来像这样
1myname

作为
mysql
命令行工具的一部分,有一个简单的xml输出-请参见此处-

命令行参数
--xml
-但输出如下所示
1myname

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

否则,您可以自己获取代码中的resultset&filter/calculate

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


否则,您可以自己在代码中获取结果集&filter/calculate。

您能举例说明您希望输出的样子吗?还有,你说你在挣扎——这是否意味着你可以向我们展示一些尝试?您是想在SQL中实现这一点,还是使用其他编程语言?可能的重复您能举个例子说明您希望输出的样子吗?还有,你说你在挣扎——这是否意味着你可以向我们展示一些尝试?您是要在SQL中执行此操作,还是使用其他编程语言?可能是重复的
ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped