I have the following oracle function , where it has num_list as input of comma separated list , and then check if the numbers in this list exists in certain table :
create or replace FUNCTION get_num_exist (num_list varchar2,separator varchar2)
RETURN nbs PIPELINED
as
row_type nb;
begin
with numbers as
(select regexp_substr(num_list,'[^'||separator||']+', 1, level)num_
from dual
connect by regexp_substr(num_list, '[^'||separator||']+', 1, level) is not null)
for r_row in (select * from numbers
where num_ in (select phone_number
from phone_numbers) )
loop
PIPE ROW(nb(r_row.num_));
end loop;
return;
end;
but it's giving a syntax error at the level of for loop.
Any help would be appreciated.
for r_row in (with numbers as (...) select * from numbers ...