coldfusion - returning the query row with the way the columns are called in sql query -


i have query calling columns way want, cannot use columnlist of query because sorts column alphabatically, thing need specific row of query , associated columns in structure:

so here function trying bring columns in manner want:

<cffunction name="rowtostruct" access="public" returntype="struct" output="false">     <cfargument name="queryobj" type="query" required="true" />     <cfargument name="row" type="numeric" required="true" />     <cfset var returnstruct = structnew()>     <cfset var colname = "">     <cfset arguments.queryobj = arraytolist(arguments.queryobj.getmeta().getcolumnlabels())>             <cfloop list="#arguments.queryobj#" index="colname">       <cfset "returnstruct.#colname#" = arguments.queryobj[colname][arguments.row]>     </cfloop>     <cfreturn returnstruct/> </cffunction> 

before above change function below:

<cffunction name="rowtostruct" access="public" returntype="struct" output="false">     <cfargument name="queryobj" type="query" required="true" />     <cfargument name="row" type="numeric" required="true" />      <cfset var returnstruct = structnew()>     <cfset var colname = "">      <cfloop list="#arguments.queryobj.columnlist#" index="colname">       <cfset "returnstruct.#colname#" = arguments.queryobj[colname][arguments.row]>     </cfloop>      <cfreturn returnstruct/> </cffunction> 

mine above 1 giving me error:

you have attempted dereference scalar variable of type class java.lang.string structure members.

the getmetadata() function returns columns in order defined in original statement. docs: getmetadata.

i can't see why code produce error, although i'd this:

<cfset returnstruct[colname] = arguments.queryobj[colname][arguments.row]> 

can update question exact error displays on screen, including code focuses on, , line numbers concerned (switch robust exception handling on, if it's not on already)


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

javascript - Create websocket without connecting -

android - Linear layout children not scrolling -