CREAR CURSOR A STRING O VARCHAR Crear Función create or replace function join ( 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 join; Prueba select join(cursor(SELECT 'A' AS LETRA FROM DUAL UNION SELECT 'B' AS LETRA FROM DUAL),'-') from dual; Resultado 2 A-B
Entradas
Mostrando entradas de octubre, 2014
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
CREAR FUNCION SPLIT Crear Tipo create or replace type split_tbl as table of varchar2(32767); Crear Función 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; Prueba SELECT * FROM TABLE...