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!

Convert string to column

user5060122Aug 26 2010 — edited Aug 26 2010
I am somewhat of a novice in SQL, and would like to know if syntax exists to convert a string to a column.


There are two parameters being passed, one of which is the column name.
The column comes across as: ab."NODE_02" where ab is the table identifier and "NODE_02" is the column name.
Unfortunately, the identifier (ab) constantly changes. It could be ab, ac....up to af; I need to eliminate the identifier then use the result in a WHERE clause.


So, I tried a substring to get the actual column name:

select SUBSTR('ab."NODE_02"',5,length('ab."NODE_02"')-5) from dual returns NODE_02

NODE_02 is a column name in the d_entity table.

I would like to have something like this in my where clause:

WHERE
(select SUBSTR('ab."NODE_02"',5,length('ab."NODE_02"')-5) from dual) = 'SOME PASSED PARAMETER'

should translate to :

WHERE
NODE_02 IN ('SOME PASSED PARAMETER')

Is there any syntax that converts a string to a column?

I've been searching for a while, but can't find anything...any help would be appreciated!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2010
Added on Aug 26 2010
3 comments
4,072 views