问题
I'm getting and error when I tried to do a query of query.
Table named allData was not found in memory. The name is misspelled or the table is not defined.
I have an excel document and I'm outputting to a coldfusion var called allData, then I'm doing a query on that var. but I'm getting an error:
What am I doing wrong? The first dump shows the table appropriately.
function name="validateExcel" access="public" output="yes" returnType="void"
hint="search for dogs">
<cfspreadsheet
action="read"
src="#SESSION.theExcelFile#"
headerrow= "1"
excludeHeaderRow = "true"
query = "allData"
rows = "1-25"/>
<cfdump var = "#allData#"/>
<cfset rotCheck = new Query(
sql = "SELECT * FROM allData where dogType like '%rot'",
dbtype = "query"
) />
<cfset dogResult = rotCheck.execute().getResult() />
<cfdump
var = "#dogResult#" />
</cffunction>
回答1:
(From comments ...)
I have to run, but short answer - the query variable from the spreadsheet is not in scope within the Query.cfc. (The documentation on Query.cfc is somewhat lacking IMO. ) Either pass in the query object as a parameter ie new Query(...., allData=allData)
or use a <cfquery> instead.
回答2:
Given that the dump works, the allData variable exists. A cfquery tag with the appropriate attributes will solve your problem for you.
来源:https://stackoverflow.com/questions/21803872/query-of-queries-failing-in-coldfusion-10