• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

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


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.
0
RussoMA
Asked:
RussoMA
  • 3
  • 2
1 Solution
 
mrichmonCommented:
<cfif pcomor.recordcount lt nocomor>

should be

<cfif pcomor.recordcount lS nocomor>

or
<cfif pcomor.recordcount EQ nocomor>
0
 
RussoMAAuthor 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.

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

Then can you show some more code....
0
 
RussoMAAuthor 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.
0
 
RussoMAAuthor Commented:
well there it is, it should be comorcount, not nocomor

blah
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now