There is no reason to change the column name dynamically - it is similar to the variable name in the procedural code - it is just a label that you can reference later in your code, so you do not want it to change at runtime.
I assume that you are actually after this - a way to format the output (for example, to print in a report) differently depending on the data. In this case, I would generate the header text as a separate column in the query, for example:
SELECT 1 AS mydata ,case when 2 = 1 then 'name1' when 1 = 1 then 'name2' end AS myheader FROM dual;
The calling procedure then takes the values ββreturned for mydata and myheader, and formats them for output as necessary.
Jeffrey kemp
source share