Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Column Name returned by function in SELECT statement

zwornikFeb 17 2013 — edited Feb 17 2013
Hi

Output from my function (RETURN data type is VARCHAR2) is column name. I want to use it directly in my SELECT statement. Below is simplified example of this:

--- Function
CREATE OR REPLACE FUNCTION simple RETURN varchar2 IS
BEGIN
RETURN ‘my_column’;
END simple;
--- Select
SELECT simple FROM my_table;

This does not work. It seems that output from function is passed in quotation i.e.
SELECT ‘my_column’ FROM my_table;
So the output from SELECT is a list of rows populated with values my_table:

COLUMN simple
ROW1 my_column
ROW2 my_column
ROW3 my_column


Can please someone help me with this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2013
Added on Feb 17 2013
14 comments
12,046 views