Using a comma delimited string in the 'where in ()' clause.
696834Sep 24 2009 — edited Aug 14 2013I 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