Solved

Query of Queries Issues

Posted on 2013-06-26
11
277 Views
Last Modified: 2013-06-28
I have the following query, does not seems to work i am using CF10. it is showing nothing:

<cfquery name = "qryCPTDetails" datasource=#request.DSN# >
      SELECT response as response FROM table WHERE PFORMID=
      (SELECT MAX(PFORMID) FROM pForms WHERE patientId=#patind# and formId=11)
</cfquery>
<cfdump var="#qryCPTDetails#">
<cfquery name = "qryCPTDetailsPending" dbtype="query">
      SELECT * from qryCPTDetails
    where #GetToken(response,2,'ü')# = 'pending'
</cfquery>


string is like this

22208 :  ADL SEGünoncertifiedñ06/23/2013
i tried even using the function inside the cfquery, it still throws error, still lost what causing this
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 39280459
m not sure,

but can u try with this one.

SELECT ASCII('ü'),CHAR(252)

<cfquery name = "qryCPTDetailsPending" dbtype="query">
      SELECT * from qryCPTDetails 
    where #GetToken(response,2,CHR(252))# = 'pending'
</cfquery>

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39280584
thanks but this is not a related answer, my question why CF functions does not inside cfquery, i know they work, but why not in CF 10. Maybe i am missing something
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 39281458
query of queries have very limited allowed functions. You can't even do things like

left(response)


What are you trying to do?
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 52

Expert Comment

by:_agx_
ID: 39281794
I think the closest you can get is to use LIKE.  Don't forget QoQ's are case sensitive too

WHERE  lower(response) LIKE <cfqueryparam value"%üpendingü%" cfsqltype="cf_sql_varchar">

Open in new window


query of queries have very limited allowed functions.

Yep. IIRC, the only functions QoQ's supports are:  

* UPPER()
* LOWER()
* CAST()

Maybe one more, but nothing else.
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39282061
ok, that is limitation of QoQ, why i am unable to use the function inside the cfquery which uses the datasource
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 39282097
you say you are getting an error...please post it
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39282130
why i am unable to use the function inside the cfquery which uses the datasource

Because CF code can't run inside a database.  The two are totally separate. CF knows nothing about SQL and your db knows nothing about CFML.

When you run a cfquery, the CF server first translates all the variables/functions:

<cfset something = "john"
<cfquery name="q" ...>
        SELECT Columns FROM Table WHERE ColumnName = '#something#'
</cfquery>

into plain text values.  Then plugs them into the SQL string:

      SELECT Columns FROM Table WHERE ColumnName = 'john'

Finally it sends the plain text sql on to the db.  The db never sees any CF variables or functions. They're evaluated long before the SQL ever makes it to the db.
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39282166
ok, i think i missing something here :

SELECT {fn Left(Title, 50)} As ShortTitle
  FROM mytable

Left is also a CF Function and Left is also in sql [so probably it is referring to the scalar function which is present in sql]

correct me if i am wrong
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39282240
Correct.  Though they both have left() functions, that statement is using your database's left() function - not the CF #left()# function.
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 39284281
Not that it really matters but I'd point out that my answer that QofQ can't do that is correct....
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39285264
I agree with Sid. The question was "what's causing this error".  The correct answer is QoQ's don't support it. My remarks just elaborate on that, but the correct answer was already given.
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question