We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

ERROR:"Complex object types cannot be converted to simple values." (in a cfloop statement)

RussoMA
RussoMA asked
on
Medium Priority
991 Views
Last Modified: 2013-12-24

Error Occurred While Processing Request  
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.
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a <CFIF> tag. This was possible in ColdFusion 2.0 but creates an error in later versions.
 
 
The error occurred in C:\Inetpub\wwwroot\reporting4.cfm: line 172
Called from C:\Inetpub\wwwroot\reporting4.cfm: line 171
Called from C:\Inetpub\wwwroot\reporting4.cfm: line 156
Called from C:\Inetpub\wwwroot\reporting4.cfm: line 1
 
170 : #Comor#,
171 : </cfoutput><cfoutput>
172 : <cfif pcomor.recordcount lt nocomor><cfset commacount = pcomor.recordcount - nocomor><cfloop index="x" from="1" to="#commacount#">,</cfloop></cfif>
173 : #dateformat(LastFUDate,'mm/dd/yyyy')#,#LosttoFU#,#Location#,
174 : <cfquery datasource="prostate" name="pdiagstag">

 ____<end of error>____
 
here's the background

variables:
pcomor = query
nocomor = number set earlier by a query

the line that is being referred to with the error:
<cfif pcomor.recordcount lt nocomor><cfset commacount = pcomor.recordcount - nocomor><cfloop index="x" from="1" to="#commacount#">,</cfloop></cfif>

what I am doing is earlier i have a query set up that tells the max count of records that could possibly be spanned across the CSV output i am creating.  (this is nocomor variable)
when i loop through some of the inner queries in my dataset, they may not have as many elements of data, so i am trying to add a , (comma) after those for each missing element
(this is the [pcomor.recordcount - nocomor] expression which i want to use for my loop variable to tell the loop how many extra comma's are needed to express the elements)

any alternate way to do this, or finding what i need to do in my code will be acknowledged as correct.
Comment
Watch Question

Commented:
<cfif pcomor.recordcount lt nocomor>

should be

<cfif pcomor.recordcount lS nocomor>

or
<cfif pcomor.recordcount EQ nocomor>

Author

Commented:
no, i am pretty sure i want it to only do that if the recordcount is less than the max possible number of rows

data i want to look like this:

data1,data2,data3  (where it doesnt call the loop)
data1,data2,,         (where it calls the loop and adds 1 comma [pcomor.recordcount is 2, nocomor is 3])
data1,,,                 (add 2 commas, [pcomor.recordcount is 1, nocomor 3])

(i think i just answered my own question there, let me test)  nope, still same problem

but now my expression is <cfset commacount = nocomor - pcomor.recordcount>

because that pcomor query runs within a loop for each row of data.  it is just a small subsection of the rest of the data that is on the same row.

Commented:
Oh is that a LT - it looked like an IT as in a typo.

Then can you show some more code....

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
here's the code for the count variable:

<cfquery datasource="mydata1" name="nocomor">
SELECT PatientCoMor.PatientSer, Count(PatientCoMor.PatientSer) AS CountOfPatientSer
FROM PatientCoMor INNER JOIN CoMor ON PatientCoMor.CoMorSer = CoMor.CoMorSer
GROUP BY PatientCoMor.PatientSer
</cfquery>
<cfset comorcount = 0>
<cfoutput query="nocomor">
<cfif countofpatientser gt comorcount><cfset comorcount = countofpatientser></cfif>
</cfoutput>

here's the area around the error:

<cfquery datasource="mydata1" name="pcomor">
SELECT CoMor.CoMor, PatientCoMor.PatientSer
FROM PatientCoMorINNER JOIN CoMorb ON PatientCoMor.CoMorSer = CoMorb.CoMorSer
WHERE PatientComor.PatientSer like '#PatientSer#'
</cfquery>
<cfoutput query="pcomor">
#Comor#,
</cfoutput><cfoutput>
<cfif pcomor.recordcount lt nocomor><cfset commacount = nocomor - pcomor.recordcount><cfloop index="x" from="1" to="#commacount#">,</cfloop></cfif>

that code is encapsulated within a cfloop that holds the variable PatientSer as the active record and it is a cfloop query loop, just to rule out duplication of the index variable.

Author

Commented:
well there it is, it should be comorcount, not nocomor

blah
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.