Search code examples
coldfusioncoldfusion-2016

Query Of Queries runtime error: Table name was not found in memory


I am getting a coldfusion error on referencing query from application variable.

Application.Shops is an application variable and is a query referenced in another file.

<cfquery name="qFilterLocations" dbtype="query">
    SELECT * FROM Application.Shops
</cfquery>

However, I do get 'Error Executing Database Query. Query Of Queries runtime error.Table named Application.Shops was not found in memory. The name is misspelled or the table is not defined.

I don't understand what is wrong here.


Solution

  • It appears that CF is interpreting the dot notation in a specific way (see https://helpx.adobe.com/coldfusion/developing-applications/accessing-and-using-data/using-query-of-queries/query-of-queries-user-guide.html). I would restructure the code in the following way:

    <cfset qShops = Application.Shops>
    <cfquery name="qFilterLocations" dbtype="query">
        SELECT * FROM qShops
    </cfquery>
    

    Follow Up: I was able to run the following in CF2018 with no issue. As @SOS suggested, this is likely a specific environment issue.

    <cfquery datasource="myDS" name="application.shops">
        select 1 from dual
    </cfquery>
    
    <cfdump var="#application.shops#">
    
    <cfquery dbtype="query" name="qResult">
        select * from application.shops
    </cfquery>
    
    <cfdump var="#qResult#">
    

    Both query results are dumped without error.