- 출처 : http://blog.naver.com/byurynet/40057155699 -
create or replace function UT_GETJOIN
/******************************************************************************
FUNCTION NAME : UT_GETJOIN
Description : ROW 결과값을 구분자를 통해 컬럼으로 표현
> select UT_GETJOIN(CURSOR(select code_id from mold_mes_mcode where code_ty='VSTAT'), '_') from dual
> 1_2_3_B_C_
Parameter
p_cursor : cursor
p_del : 컬럼 구분자
Result
varchar2(32767) : aaa;bbb;ccc;
******************************************************************************/
(
p_cursor sys_refcursor,
p_del varchar2 := ';'
) return varchar2
is
l_value varchar2(32767);
l_result varchar2(32767) := '';
BEGIN
LOOP
FETCH p_cursor INTO l_value;
EXIT WHEN p_cursor%NOTFOUND;
IF l_result IS NOT NULL THEN
l_result := l_result || p_del;
END IF;
l_result := l_result || l_value;
END LOOP;
RETURN l_result;
END UT_GETJOIN;
[출처] Row결과값을 구분자를 통해서 칼럼으로 표현|작성자 개꿈