pure SQL but not very well tested ...
select to_number(substr(postfix, 2, instr(postfix, ',' ,2)-2)) id from ( select substr(val, instr(val, ',', 1, n)) postfix from (select ',101,102,103,' val from dual) , ( select level n from dual connect by level < 10) where instr(val, ',', 1, n) > 0) where instr(postfix, ',' ,2)> 2;
EDIT : improved
select substr(postfix, 1, instr(postfix, ',' ,1)-1) from ( select substr(val, instr(val, ',',1, level)+1) postfix from (select ',101,102,103,' val from dual) connect by instr(val, ',', 2, level) > 0 );
Note:
- pre / post corrects your lines with commas
accept the upper limit (10 in the example) according to your needs (not required in the improved version).- use the in_list table function specified by Justing Cave, which is probably better :)
credit: something like this in Stefan Farul's book Restoring SQL Applications (O'Reilly)