Question

Here is the scenario, I am getting the result-set from the following code and i am running the following below query after getting the result from cfdump, but it shows empty second dump, do not why?

can anyone check what is wrong:

<cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''>
  <cfset answers = initial.getSearchResults('#URL#')>
  <cfset flag = 'yes'>
</cfif>

<cfchart format="png" scalefrom="0" scaleto="#answers.recordcount#" show3d="Yes">
    <cfchartseries type="bar" serieslabel="Support Tickets" seriescolor="##009933">
    <cfdump var="#answers#">
    <cfoutput query="answers">
        <cfquery dbtype="query" name="myString">
            SELECT count(*) as strvalue 
            FROM answers 
            WHERE status = "#trim(answers.status)#"
        </cfquery>
    <cfchartdata item="#Status#" value="#myString.strvalue#">
    </cfoutput>
    <cfdump var="#myString#">
   </cfchartseries>
   </cfchart>

This is howing an issue, it does not anything: do not know why:

<cfdump var="#myString#">

Edit

Screenshot below

enter image description here

Was it helpful?

Solution

Based on the screenshot provided, the following is suggested

<cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''>
  <cfset answers = initial.getSearchResults(URL)>
  <cfset flag = 'yes'>
</cfif>


<cfquery dbtype="query" name="qrySummary">
    SELECT status, count(status) as strvalue 
    FROM   answers 
    GROUP BY status
    ORDER BY status
</cfquery>

<cfdump var="#qrySummary#">


<cfchart format="png" scalefrom="0" scaleto="#answers.recordcount#" show3d="Yes">
  <cfchartseries type="bar" serieslabel="Support Tickets" seriescolor="##009933">
  <cfoutput query="qrySummary">
      <cfchartdata item="#Status#" value="#strvalue#">
  </cfoutput>
  </cfchartseries>
</cfchart>

Also see

Query of query support for aggregate functions

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0e4fd-7ff0.html#WSc3ff6d0ea77859461172e0811cbec0e4fd-7fcc

OTHER TIPS

Copying structs

First off

<cfset answers = initial.getSearchResults('#URL#')>

Won't work. If we ignore the dangers with this, you can

<cfset answers = initial.getSearchResults(URL)>

<cfdump> can't generate any output inside of a <cfchart>. If you want to a dump, it has to be outside of the chart. To debug your data consider using something like this:

<cfdump var="#answers#">
<cfoutput query="answers">
    <cfquery dbtype="query" name="myString">
        SELECT count(*) as strvalue 
        FROM answers 
        WHERE status = <cfqueryparam value = "trim(answers.status)#" cfsqltype = "cf_sql_varchar">
    </cfquery>
    #myString.strvalue# 
</cfoutput>
<cfdump var="#myString#">

Also consider, changing code so that you don't have have an inner query. You will get better performance and it will be easier to debug.

UPDATE

<cfdump var="#answers#">
<!--- at this point, confirm that you are returning a query --->


<cfoutput query="answers">
    <cfquery dbtype="query" name="myString">
        SELECT count(status) as strvalue 
        FROM   answers 
        WHERE  status = <cfqueryparam value = "trim(answers.status)#" cfsqltype = "cf_sql_varchar">
    </cfquery>

    <!--- here you should have a series of queries with one row, one column --->
    <cfdump var="#myString#">
</cfoutput>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top