Skip to main content
Participating Frequently
May 27, 2008
Question

CFC Query Return not working

  • May 27, 2008
  • 3 replies
  • 573 views
Hello All,

Here is my code within the CFC:

<cffunction name="getThisProjectNumber" access="remote" returntype="string" output="false">
<cfargument name="thisProjectName" default="string" required="yes">
<cfset var selectedNumber = ""/>

<cfquery name="getProjectNumber" datasource="#datasource#">
SELECT creativeConfirmationNo.projectNumber,
creativeProjects.projectNameID, creativeProjects.projectName
FROM creativeConfirmationNo INNER JOIN
creativeProjects ON creativeConfirmationNo.projectNameID =
creativeProjects.projectNameID
WHERE (creativeProjects.projectName = '#arguments.thisProjectName#')
</cfquery>

<cfset selectedNumber = getProjectNumber.creativeConfirmationNo.projectNumber>

<cfreturn selectedNumber>
</cffunction>

I get this error with the above query:

CREATIVECONFIRMATIONNO.PROJECTNUMBER is undefined in GETPROJECTNUMBER.

So then I tried using the "as" projectNumber within the query so my <cfset selectedNumber = getProjectNumber.projectNumber >

Neither one is working??? Any suggestions/solutions would be greatly appreciated!

Cheers!
This topic has been closed for replies.

3 replies

Inspiring
May 27, 2008
So when you run the query outside coldfusion you get one row but inside coldfusion does not give you any rows?

Step Number 1 - make sure you are using the same database.

Step Number 2 - make sure you have de-bugging turned on in coldfusion. Copy and paste the sql from your debugging info into Query Analyzer, or whatever you are using, to make sure it's the same query.
kdennis4Author
Participating Frequently
May 27, 2008
I am posting this one to the CF Group... However, I'm using Flex 3. So I took another try at this one like this:

<cfloop query="getProjectNumber">
<cfset selectedNumber = creativeConfirmationNo.projectNumber[1]>
</cfloop>
<cfreturn selectedNumber>

Still not returning anything to my Flex App.... Not sure if anyone else is working with Flex in this group, but maybe there is another way that I can test it. Sure do appreciate all the help!

Cheers
kdennis4Author
Participating Frequently
May 27, 2008
Hello All,

Thanks for all the suggestions.... it was in my Flex app. At any rate this will help me with future queries. I really do appreciate all the feedback!

Cheers
Inspiring
May 27, 2008
> give that column an alias. also specify a row number.

Added to that, when faced with errors that suggest the contents of a
variable are not what you expect them to be, a good place to start is to
<cfdump> the variable to see what it *does* contain. I reckon had you done
that, you'd spot where you're going wrong...

--
Adam
Inspiring
May 27, 2008
Ensure your query actually returns some data. Also specify a row number.

From an efficiency perspective, if you are only returning one column, don't bother selecting the others.
kdennis4Author
Participating Frequently
May 27, 2008
Here is what I have so far within my CFC now:

<cfquery name="getProjectNumber" datasource="#datasource#">
SELECT creativeConfirmationNo.projectNumber as ProjectNumber
FROM creativeConfirmationNo INNER JOIN
creativeProjects ON creativeConfirmationNo.projectNameID =
creativeProjects.projectNameID
WHERE (creativeProjects.projectName = '#arguments.thisProjectName#')
</cfquery>

<cfset selectedNumber = getProjectNumber.ProjectNumber[1]>

<cfreturn selectedNumber>

I have run my query in SQL server and I'm getting the one result, however it is still not returning the data. I've even placed a <cfset selectedNumber = "here">... and that shows up???? Any other suggestions would be greatly appreciated.

Cheers