ERROR:"Complex object types cannot be converted to simple values." (in a cfloop statement)
Posted on 2006-03-20
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
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.