ColdFusion: how to access dynamic column names

84 Views Asked by At

ColdFusion 2018.

I ran a pivot query in Oracle that generated following column headers.

I need to output result of this query into html table.

How do I access these column headers?

enter image description here

1

There are 1 best solutions below

0
Dan Bracuk On BEST ANSWER

Like this, if you want the columns in alphabetetical order:

<table>
<tr>
<cfoutput>
<cfloop list="#queryname.columnlist#" index="header">
<td>#header#</td>
</cfloop>
</cfoutput>
</tr>

Like this, if you want the columns in the order they appear in the query:

<table>
<tr>
<cfoutput>
<cfloop array="#queryname.getcolumnlist()#" item="header">
<td>#header#</td>
</cfloop>
</cfoutput>
</tr>