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

Passing Query to CFC

Contributor ,
Nov 03, 2006 Nov 03, 2006

Copy link to clipboard

Copied

I am passing a query to a cfc. When I dump the query in the cfc it looks fine. However, when I attempt to loop over the query I get the following error: Complex object types cannot be converted to simple values.
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.

Here is the code:

<cffunction name="updateTYC_Card_Master" access="public" returntype="void">
<cfargument name="GoodRequests" required="yes" type="query">
<cfargument name="dsn" required="yes" type="string">
<cfargument name="newjobNo" required="yes" type="string">

<!--- <cfdump var="#arguments.goodRequests#">
<cfabort> --->

<cfloop query="#ARGUMENTS.GoodRequests#">
<cfquery name="UpdateTYC_Card_Master" datasource="#ARGUMENTS.dsn#">
Update READONLY.TYC_Card_Master
Set Job_Key = #ARGUMENTS.jobNo#
Where custno = #custno#
And job_key = -1
</cfquery>
</cfloop>
</cffunction>

How would I go about being able to use the contents of the query that I passed into the cfc. I've never passed in a query before. Thanks for the help.

mark
TOPICS
Advanced techniques

Views

630

Translate

Translate

Report

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

Contributor , Nov 03, 2006 Nov 03, 2006
Dan,

Thanks for the assist. I was so wrapped up in the passing of the query that I overlooked the obvious. I'll give it a go using the valueList.
Again, thanks for the help.

Mark

Votes

Translate

Translate
LEGEND ,
Nov 03, 2006 Nov 03, 2006

Copy link to clipboard

Copied

It has nothing to do with your query. This
<cfargument name="newjobNo" required="yes" type="string">

does not match this
Set Job_Key = #ARGUMENTS.jobNo#

Also, your argument specifies a string but your sql does not have quotes.

Finally, since you are setting all the records to the same new job number, instead of running a query inside a loop, it is probably more efficient to run one query which includes something like

where custno in (#ValueList(arguments.yourquery.custno)#)

Votes

Translate

Translate

Report

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
Contributor ,
Nov 03, 2006 Nov 03, 2006

Copy link to clipboard

Copied

Dan,

Thanks for the assist. I was so wrapped up in the passing of the query that I overlooked the obvious. I'll give it a go using the valueList.
Again, thanks for the help.

Mark

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 03, 2006 Nov 03, 2006

Copy link to clipboard

Copied

LATEST
> It has nothing to do with your query. This

Well it kind of does.

> <cfloop query="#ARGUMENTS.GoodRequests#">

The query parameter takes the NAME of the query, not the *actual query*.

Lose the pound-signs.

--
Adam

Votes

Translate

Translate

Report

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
Documentation