Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Query of queries question

Participant ,
Apr 29, 2009 Apr 29, 2009

Can you query a query created using queryNew()?

When I try the following code I get an error:

"Query Of Queries syntax error.
Encountered "qData . user. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition, "

Code:

<cfset qData = queryNew("tool,user,community,fm01,fm02,fm03,fm04,fm05,fm06,fm07,fm08,fm09,fm10,fm11,fm12,fy")>
<cfset temp = #queryAddRow(qData)#>
<cfset temp = #querysetCell(qData,"tool","empty")#>
<cfset temp = #querysetCell(qData,"user","Bob")#>

<cfquery  dbtype="query" name="chkQdata">
       SELECT *
       FROM qData
       WHERE qData.user = 'Bob'
</cfquery>

553
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Apr 29, 2009 Apr 29, 2009

I just tried the code you supplied, adding in two cfdump tags (the first to dump the qData query and the second to dump the chkQdata query). Everything worked fine exactly as you had it on Railo 3.1. It did not work (threw the error you got) on CF 8.0.1.

If I removed the WHERE clause from the chkQdata query, it runs (no errors) in CF 8.0.1.

To get it to run as you want in CF8, change the user column. This appears to be a reserved keyword for CF8. While I did not verify that exactly, if I change yo

...
Translate
Advocate ,
Apr 29, 2009 Apr 29, 2009

I just tried the code you supplied, adding in two cfdump tags (the first to dump the qData query and the second to dump the chkQdata query). Everything worked fine exactly as you had it on Railo 3.1. It did not work (threw the error you got) on CF 8.0.1.

If I removed the WHERE clause from the chkQdata query, it runs (no errors) in CF 8.0.1.

To get it to run as you want in CF8, change the user column. This appears to be a reserved keyword for CF8. While I did not verify that exactly, if I change your original query to be tool = 'emtpy', it runs. Also, renaming the user column to usr results in the script running properly.

Here's the code I got to work in Railo 3.1 and CF8:

<cfset qData = queryNew("tool,usr,community,fm01,fm02,fm03,fm04,fm05,fm06,fm07,fm08,fm09,fm10,fm11,fm12,fy","varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar")>

<cfset temp = #queryAddRow(qData)#>

<cfset temp = #querysetCell(qData,"tool","empty")#>

<cfset temp = #querysetCell(qData,"usr","Bob")#>

<cfdump var="#qData#" />

<cfquery dbtype="query" name="chkQdata">

SELECT *

FROM qData

WHERE usr = 'Bob'

</cfquery>

<cfdump var="#chkQdata#" />

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2009 Apr 29, 2009

Try:

<cfquery  dbtype="query" name="chkQdata">
       SELECT *
       FROM qData
       WHERE qData.user LIKE 'Bob'
</cfquery>

Text fields (at least in my experience with MS SQL) can't use a '='

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 30, 2009 Apr 30, 2009
LATEST

'like' had the same error issue.  It was that user is a reserved word.  It was odd because I never use the word user, usually I do 'uName' or 'userN'.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources