• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Issue with CFQUERY results

Guest
Mar 05, 2010 Mar 05, 2010

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.

TOPICS
Advanced techniques

Views

469

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Mar 05, 2010 Mar 05, 2010

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]

Votes

Translate

Translate
Valorous Hero ,
Mar 05, 2010 Mar 05, 2010

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]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

@cfsearching - Thanks a bunch, that did the trick.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2010 Mar 06, 2010

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

LATEST

@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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation