Copy link to clipboard
Copied
Hello,
Im building a data export and trying to build the columns in the export file dynamically by storing and pulling them out of a seperate database table. My issue is with a column called "COL-1". Im building the data export as using the method below, then putting the two variables together to create the export..
<cfsavecontent variable="dataheader"><cfoutput query="getColumns">#getColumns.column_nm#|</cfoutput><cfoutput>#chr(13)##chr(10)#</cfoutput></cfsavecontent>
<cfsavecontent variable="datarecords">
<cfoutput query="getData">
<cfloop query="getColumns">
<!--- below line is where error occurs --->
<cfset variables.col_value = '#evaluate("getData." & getColumns.column_nm)#|'>
</cfloop>
</cfoutput>
</cfsavecontent>
<cfset variables.data_export = dataheader & datarecords>
Error Occurred While Processing Request Element COL is undefined in GETDATA.
How do I get CF to evaluate() the entire column name (COL-1)??
Message was edited by: BigFeetBigShoes - reformatted code example.
How do I get CF to evaluate() the entire column name
(COL-1)??
You can use array notation instead of evaluate. The basic syntax is
yourQueryName[columnName][rowNumber]
Copy link to clipboard
Copied
How do I get CF to evaluate() the entire column name
(COL-1)??
You can use array notation instead of evaluate. The basic syntax is
yourQueryName[columnName][rowNumber]
Copy link to clipboard
Copied
@cfsearching - Thanks a bunch, that did the trick.
Copy link to clipboard
Copied
In addition to the previous answer, you have a logic problem in that you are overwriting your col_val variable each time you go through your loop.
Copy link to clipboard
Copied
@Dan - thanks. In the actual code I have a list append function Im referencing after that statement. So its there, just not in this example, good looking out though.