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 a comma delimited string in the 'where in ()' clause.

696834Sep 24 2009 — edited Aug 14 2013
I am trying to use a comma delimited string of numbers inside a 'where in' clause like this.

stringOfNumbers := '2, 21';

select *
from table
where id in (stringOfNumbers);

This of course becomes

select *
from table
where id in ('1,21');

As you can see this does not work.

Both (1,21) and ('1','21') works, but my problem is how to convert a comma delimited string into one of those formats?

The comma delimited string is actually made like this inside a loop:

stringOfNumber := v_idsMatch || v_resdata.res_id || ''',''';

(I do another step trimming the string for the extra ',' at the end).

Any advice?

Regards
Runski
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2013
Added on Sep 24 2009
15 comments
25,500 views