Skip to main content
Known Participant
September 16, 2010
Answered

List of Queries Run?

  • September 16, 2010
  • 1 reply
  • 740 views

I'm on a public server and cannot get debug information to show. Mostly I want to see the queries that have run on the page. Is there an existing structure I can reference to get a list of queries that have run on a page?

This topic has been closed for replies.
Correct answer Owainnorth

Thanks to both responses. I was able to parse a list of the variable names but how do I test or parse each individual structure? Assume that one screen has a query named getTerritories.

<cfoutput>

Variable List: <br />

<cfloop list="#structKeyList(variables)#" index="ii">

#ii# <br />

</cfloop>

</cfoutput>


I think in order to get the SQL from more than one query, you'll need to add the result="varname" attribute to all the queries on the page.

Here's an example page, using an Oracle DB:

<cfquery name="Query1" datasource="ds" username="user" password="pass" result="Query1Info" >
    SELECT 1 FROM dual
</cfquery>

<cfquery name="Query2" datasource="ds" username="user" password="pass" result="Query2Info" >
    SELECT 1 FROM dual
</cfquery>

<cfloop collection="#VARIABLES#" item="EachVar">
    <cfif isQuery(VARIABLES[EachVar]) >
        <cfdump var="#VARIABLES[EachVar]#" label="#EachVar#" />
    </cfif>
</cfloop>

Hope that helps.

1 reply

Owainnorth
Inspiring
September 20, 2010

If they're just set within a page rather than nested within a function you might be able to see them by dumping out the VARIABLES scope.

O.

Inspiring
September 20, 2010

If you want to fine tune this approach, you could loop through the variables collection and use isQuery to identify the queries.

NewPrismAuthor
Known Participant
September 20, 2010

Thanks to both responses. I was able to parse a list of the variable names but how do I test or parse each individual structure? Assume that one screen has a query named getTerritories.

<cfoutput>

Variable List: <br />

<cfloop list="#structKeyList(variables)#" index="ii">

#ii# <br />

</cfloop>

</cfoutput>