I have a string of numbers separated by comma like '7845,6986,2548' I want to split comma and pass result to IN clause of select statement I used to use this function:
create or replace TYPE t_in_list_tab as table of varchar2(4000);
create or replace FUNCTION in_list (p_in_list IN VARCHAR2)
RETURN t_in_list_tab
AS
l_tab t_in_list_tab := t_in_list_tab();
l_text VARCHAR2(32767) := p_in_list || ',';
l_idx NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
l_tab.extend;
l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;
RETURN l_tab;
END;
the return type of this function is varchar2 but my column type is number, I tried to use TO_NUMBER like:
select * from my_tbl where col1 IN (TO_NUMBER(select * from table(IN_LIST('7845,6986,2548'))));
but it didn't work, any help?