将 ColdFusion 服务器从 CF9 升级到 CF21 后,ColdFusion 查询出现问题

发布于 2025-01-11 09:22:41 字数 1183 浏览 0 评论 0原文

我无法弄清楚这一点。我的公司最近将 ColdFusion 服务器从 CF9 升级到 CF2021。我的页面之一使用查询的查询来运行。升级之前,该页面运行良好。但是升级后,查询 where 语句的查询没有返回任何结果。即使原始查询有数据。数据来自DB2数据源,以防随新版本发生变化。

<cfquery name         = "query_data_sample"  dbtype="query">
   SELECT
            SAMPLE_DATE
       ,    SAMPLE_NBR
       ,    SAMPLE_MISC_NBR

       ,  SUM (RECD_QTY)      AS   TTL_RECD_QTY
       ,  SUM (MISC_QTY_1)    AS   TTL_MISC_QTY_1
       ,  SUM ( 1 )           AS   TTL_COUNT
   FROM    original_query_result
   WHERE    1=1
      AND SAMPLE_DATE = <cfqueryparam value = "#original_query_result.SAMPLE_DATE#" cfsqltype = "CF_SQL_DATE">
      AND SAMPLE_NBR  = <cfqueryparam value = "#trim(original_query_result.SAMPLE_NBR)#"  cfsqltype = "CF_SQL_CHAR">
      AND SAMPLE_MISC_NBR = <cfqueryparam value = "#trim(original_query_result.SAMPLE_MISC_NBR)#"   cfsqltype = "CF_SQL_CHAR">


   GROUP BY
        SAMPLE_DATE
   ,    SAMPLE_NBR 
   ,    SAMPLE_MISC_NBR 


 </cfquery>

当我注释掉 AND 语句并转储上述查询时,我可以看到原始查询结果的输出以及所有 TTL 值和示例行。但是,如果我只想使用 AND 语句获取一行,则查询返回时找不到该行。我正在执行 cfoutput query = original_query_result 并尝试获取输出网格表中每一行上显示的总量。

任何帮助将不胜感激。我已经尝试解决这个问题一个多星期了。

I cannot figure this out. My company recently upgraded our ColdFusion Server from CF9 to CF2021. One of my pages uses queries of queries to run. Prior to the upgrade the page worked fine. However after the upgrade the query of query where statement is not returning any results. Even though the original query has the data. The data is coming from DB2 data source in case that changed with the new version.

<cfquery name         = "query_data_sample"  dbtype="query">
   SELECT
            SAMPLE_DATE
       ,    SAMPLE_NBR
       ,    SAMPLE_MISC_NBR

       ,  SUM (RECD_QTY)      AS   TTL_RECD_QTY
       ,  SUM (MISC_QTY_1)    AS   TTL_MISC_QTY_1
       ,  SUM ( 1 )           AS   TTL_COUNT
   FROM    original_query_result
   WHERE    1=1
      AND SAMPLE_DATE = <cfqueryparam value = "#original_query_result.SAMPLE_DATE#" cfsqltype = "CF_SQL_DATE">
      AND SAMPLE_NBR  = <cfqueryparam value = "#trim(original_query_result.SAMPLE_NBR)#"  cfsqltype = "CF_SQL_CHAR">
      AND SAMPLE_MISC_NBR = <cfqueryparam value = "#trim(original_query_result.SAMPLE_MISC_NBR)#"   cfsqltype = "CF_SQL_CHAR">


   GROUP BY
        SAMPLE_DATE
   ,    SAMPLE_NBR 
   ,    SAMPLE_MISC_NBR 


 </cfquery>

When I comment out the AND statements and dump out the above query I can see the output of the original_query_result with all the TTL values and Sample rows. However if I want to grab just one row with the AND statements then the query comes back as not finding the row. I am doing a cfoutput query = original_query_result and trying to get the total quantity to display on each row in my output grid table.

Any help would be greatly appreciated. I have been trying to figure this out for more then a week now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡墨 2025-01-18 09:22:41

我不久前看到了类似的东西,发现了这篇文章:

https://web.archive.org/web/20180210052449/http://blog.dkferguson.com/index.cfm/2010/2/17/Using-Querie-of-Queries-with-CFDirectory

基本上我必须转换日期并使用 cfqueryparam (就像你一样):

SAMPLE_DATE = CAST(<cfqueryparam value="#original_query_result.SAMPLE_DATE#" cfsqltype="CF_SQL_DATE"> AS date)

帖子说他们必须转换双方,但我没有找到这个。

I saw something similar a while back and found this post:

https://web.archive.org/web/20180210052449/http://blog.dkferguson.com/index.cfm/2010/2/17/Using-Querie-of-Queries-with-CFDirectory

Basically I had to CAST the date and use cfqueryparam (as you are):

SAMPLE_DATE = CAST(<cfqueryparam value="#original_query_result.SAMPLE_DATE#" cfsqltype="CF_SQL_DATE"> AS date)

The post said they had to cast both sides but I didn't find this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文