【问题标题】:case statement inside of fetchxml scriptfetchxml 脚本中的 case 语句
【发布时间】:2014-10-31 15:54:57
【问题描述】:

请注意,虽然这个问题是一个完全不同的问题,但它与this question. 直接相关

以下是为我的 SSRS 图表返回数据集的脚本:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
      <entity name="account">
        <attribute name="bio_employeesworldwide" alias="TotalWorldWideEmployees" aggregate="sum" />
        <filter>
          <condition attribute="customertypecode" operator="eq" value="2" />
        </filter>
     <link-entity name="contact" from="parentcustomerid" to="accountid" alias="contact">

        <attribute name="bio_webuseraccountstatus" alias="count_bio_webuseraccountstatus" aggregate="countcolumn" />

        <attribute name="bio_webuseraccountstatus" alias="bio_webuseraccountstatusgroupby" groupby="true" />

      </link-entity>
      </entity>
    </fetch>

bio_webuseraccountstatus 的值可以是Active, Inactive, Disabled, Pending, etc..

在 FetchXML 中,有没有办法为每个不等于“Active”的值做一个“InActive”的 case 语句?

如您所见,我一直在尝试解决此问题 within the reporting layer,但遇到了很多“字符串格式”问题。

这可以用数据集层 (fetchxml) 代替吗?

【问题讨论】:

  • 这是一个很好的问题!

标签: sql sql-server xml reporting-services fetchxml


【解决方案1】:

根据this Microsoft forum post

FetchXml 中没有等效的函数。相反,您需要返回每个字段值,并在调用代码中处理 CASE 逻辑。如果要在报表中使用此 FetchXml,那么您可以在报表的计算字段中实现 CASE 逻辑。

【讨论】:

    【解决方案2】:

    您始终可以在返回时解析 fetchxml 的输出。 因此,与其将 isreceivetravelalerts 的原始记录字段推送到屏幕、报告或数据库,不如检查状态(零或一)并重写它,并将新变量添加到输出中。笨重,但很有用。

    if ($record->isreceivetravelalerts == 1) 
    {           
        $travel_alerts = "Active"; 
    }
    
    $travel_alerts = "Inactive";
    

    【讨论】:

      猜你喜欢
      • 2014-05-27
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 2023-04-07
      • 2018-07-31
      • 1970-01-01
      相关资源
      最近更新 更多