Back to the notebook

CFC and QoQ

ColdFusion Code

CFC and QoQ

I ran into an odd problem today. I was trying to do a Query of a Query (QoQ) inside a CFC function, using a query that was executed in another function. When testing the page, ColdFusion MX (CFMX) returned an error stating that it could not find the first query in memory.

To debug, I created a function just to check whether the query existed, using the following code:


<cfif isDefined("queryName")>
    TRUE
<cfelse>
    FALSE
</cfif>

Then, right after calling this method, I added the same check in my ColdFusion page. The setup looked like this:


1. <cfinvoke component="comName" method="originalQuery">
2. <cfinclude template="comName" method="QoQ"> 
3. <cfif isDefined("queryName")>TRUE<cfelse>FALSE</cfif>

When I ran the page, the output was:


FALSE
TRUE

It seems that I will need to assign the this scope to originalQuery so that the result can be accessed throughout the CFC. I haven’t had time to test this yet (it’s the weekend—woohoo!), but I’ll look into it later unless someone already knows the reason why?

Leave a note.