创建type:
create or replace type str2tblType as table of varchar2(4000);
创建函数:
CREATE OR REPLACE FUNCTION tab2clob(p_str2tbltype str2tbltype,
p_delim IN VARCHAR2 DEFAULT ',') RETURN CLOB IS
l_result CLOB;
BEGIN
FOR cc IN (SELECT column_value
FROM TABLE(p_str2tbltype)
ORDER BY column_value) LOOP
l_result := l_result || p_delim || cc.column_value;
END LOOP;
RETURN ltrim(l_result, p_delim);
END;
调用函数效果:
select tab2clob(CAST(COLLECT(tm) AS str2tbltype)) from table