Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 533
  • Last Modified:

cfquery, columnList results display twice


i'm using this query to pull column names:

SELECT *
FROM ProdFields
WHERE 1 = 2

i'm using this to output the results:

<cfset ColList = listChangeDelims(valueList(GetCurrentProdFieldNames.columnList),",</br>")>
<cfoutput>#ColList#</cfoutput>

the table that i'm querying only has two columns currently but i view the output i see them duplicated like so:

AUTOID
PRODNAME
AUTOID
PRODNAME


any ideas why?

0
bede123
Asked:
bede123
  • 4
  • 4
  • 3
3 Solutions
 
bede123Author Commented:
just an update to this problem. it seems to repeat itself depending on how many colums there are.
i.e. i now have 5 columns so the output block repeats 5 times.
0
 
gdemariaCommented:

I am guessing you have two sets of CFOUTPUT tags, you cannot nest them unless you are grouping

Try removing the cfoutput tags

<cfset ColList = listChangeDelims(valueList(GetCurrentProdFieldNames.columnList),",</br>")>

#ColList#


0
 
bede123Author Commented:
yeah i tried that first off. but the output is just:

#ColList# and not data
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
gdemariaCommented:
Please show your block of code all around this item..
0
 
_agx_Commented:
<cfset ColList = listChangeDelims(valueList(GetCurrentProdFieldNames.columnList),",</br>")>
<cfoutput>#ColList#</cfoutput>

Why are you using valueList? ColumnList returns the names of the columns in the query. So you normally use it *instead* of valueList.  ValueList() is for when you want to generate a list of values in the query.
0
 
_agx_Commented:
To show the column names, try

<cfset ColList = listChangeDelims(GetCurrentProdFieldNames.columnList,</br>)>
<cfoutput>#ColList#</cfoutput>
0
 
_agx_Commented:
With quotes obviously :)

<cfset ColList = listChangeDelims(GetCurrentProdFieldNames.columnList, ",</br>")>
<cfoutput>#ColList#</cfoutput>
0
 
gdemariaCommented:

oh crap, of course... you are trying to show the list of column names...

Good catch agx


I couldn't see the forest through all the trees
0
 
_agx_Commented:
That was me yesterday :) Tag, you're it.
0
 
bede123Author Commented:
LOL

sorry for slow reply. had to travel home.

thanks for you input peeps.

agx was right, didnt need the value list in there. seems to be working great!

many thanks
zac
0
 
bede123Author Commented:
sorry for planting so many trees! :-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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