우선 Table 타입을 선언합니다.
create or replace type split_tbl as table of varchar2(32767);
/
함수를 선언합니다.
create or replace function split
(
p_list varchar2,
p_del varchar2
) return split_tbl pipelined
is
l_idx pls_integer;
l_list varchar2(32767) := p_list;
l_value varchar2(32767);
begin
loop
l_idx := instr(l_list,p_del);
if l_idx > 0 then
pipe row(substr(l_list,1,l_idx-1));
l_list := substr(l_list,l_idx+length(p_del));
create or replace type split_tbl as table of varchar2(32767);
/
함수를 선언합니다.
create or replace function split
(
p_list varchar2,
p_del varchar2
) return split_tbl pipelined
is
l_idx pls_integer;
l_list varchar2(32767) := p_list;
l_value varchar2(32767);
begin
loop
l_idx := instr(l_list,p_del);
if l_idx > 0 then
pipe row(substr(l_list,1,l_idx-1));
l_list := substr(l_list,l_idx+length(p_del));
else
pipe row(l_list);
exit;
end if;
end loop;
return;
end split;
/
사용법은
select * from table(split('1 2 3 4 5 6 7 8 9 10', ' '));
입니다.
출처: http://www.dulihana.com/blog/126
pipe row(l_list);
exit;
end if;
end loop;
return;
end split;
/
사용법은
select * from table(split('1 2 3 4 5 6 7 8 9 10', ' '));
입니다.
출처: http://www.dulihana.com/blog/126
댓글 없음:
댓글 쓰기