Write Oracle proc/function to create dynamic views with changing column headers
Why does it have to be one query?
Why not retrieve the column headers in one step, pull the real data in another and then stitch the two together, if that's even required?
If this is being done under application control (as opposed to a single database &quot;query&quot;), you may not need to do this &quot;reassembly&quot; at all.  It might be possible to populate your column headers separately from the real data.