我有一个问题
SELECT csedept_name,submitterdept, COUNT(execoffice_status) as 'starsgiven'
FROM Depts d
LEFT JOIN CSEReduxResponses c on d.csedept_id = c.submitterdept
.......
and YEAR ([approveddate]) =2014
and month ([approveddate]) =12
....
当我在 microsolf sql server studio 上运行时,我得到 返回 20 行,所有“submitterdept”为空。 但我不断收到此错误:
Element RECORDCOUNT is undefined in GETBRANCHSTARS.
The error occurred in stars.cfm: line 498
496 : </cfif>
497 : <cfset totalbranch =0 >
498 : <cfif getbranchstars.recordcount gt 0>
499 :
500 : <h1> Counts </h1
由于某种原因无法识别记录数。
我做错了什么?
<cfset totalbranch =0 >
<cfif getbranchstars.recordcount gt 0>
<table >
<thead><tr><th>Branch</th><th>Stars Given</th></tr></thead>
<tbody>
<cfoutput query="getbranchstars" >
<tr>
<td>#CSEDEPT_NAME#</td>
<td>#BRANCHTOTALSTARSGIVEN#</td>
</tr>
<cfset totalbranch += BRANCHTOTALSTARSGIVEN>
</cfoutput>
</tbody>
<tfoot>
<cfoutput>
<tr>
<th> </th>
<th><div align="left">#totalbranch#</div></th>
</tr>
</cfoutput>
</tfoot>
</table>
<cfelse>
<p>No Branch Department Counts</p>
</cfif>
最佳答案
我在运行在应用程序 onRequest 上切换 session 范围设置的例程时遇到此错误,这影响了关于是否运行查询的条件逻辑。当 session 范围的设置设置为执行查询时,后面的代码将根据该 session 范围的设置运行以输出数据(如果有 RECORDCOUNT)。在没有切换的情况下对同一页面的后续调用,页面运行正常。因此,显然 CF 以某种方式及时获得新 session 设置以运行查询,但没有及时运行所有内务处理以将 recordCount 附加到查询对象。我取出了是否运行查询的 session 范围条件,我不再收到丢失的 RECORDCOUNT 错误。
关于coldfusion - 为什么获取错误元素 recordcount 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27259941/