Query of Queries failing in Coldfusion 10

2019-07-23 18:09发布

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>

2条回答
该账号已被封号
2楼-- · 2019-07-23 18:25

Given that the dump works, the allData variable exists. A cfquery tag with the appropriate attributes will solve your problem for you.

查看更多
疯言疯语
3楼-- · 2019-07-23 18:28

(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.

查看更多
登录 后发表回答