Convert string to column
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!