oracle行转列的通用实现(管道函数)
--oracle行转列的通用实现:--将'A,B,C'转换为:--A--B--C--实现方法:(大家可以自由发挥)--1.定义一个类型create type type_row is table of varchar2(200);--2.创建函数create function split(p_list varchar2) return type_row pipelined IS l_idx pls_integer; v_list varchar2(50) := p_list;begin loop l_idx := instr(v_list, ','); if l_idx > 0 then pipe row(substr(v_list, 1, l_idx - 1)); v_list := substr(v_list, l_idx + length(',')); else pipe row(v_list); exit; end if; end loop; return;end;--3.转换select column_value from table(split('A,B,C'));