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!

SQL String formatting - help

527623Jul 24 2007 — edited Jul 24 2007
I have a simple sql statement that works (in my case, returns 28 rows).

select columna,
columnb
from table
where columnb in ('Value1','Value2')

Next, I can do something like:

select ''''||replace('Value1,Value2',',',''',''')||'''' from dual and it returns a string:

(''''||REPLACE('VALUE1,VALUE2',',',''',''')||'''')
--------------------------------------------------
'Value1','Value2'

What I would like to do, is combine the two statements because the "in" statement will depend on a comma separated value list that the user will supply (which is why I'm trying to format it as an "in" statement would be formatted)

I've tried:

select columna,
columnb
from table
where columnb in (select ''''||replace('Value1,Value2',',',''',''')||'''' from dual);

This SQL statement returns 0 rows instead of my 28 that I think I should get. What am I doing wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2007
Added on Jul 24 2007
4 comments
276 views