Vai al contenuto

# SPLIT

## Codice Sorgente

    FUNCTION             "SPLIT"
    (
        p_list varchar2,
        p_del varchar2 := ','
    ) return string_list
    is
        l_idx    integer;
        l_list   varchar2(32767) := p_list;

        l_value    varchar2(32767);

        l_retval   string_list;
    begin

      l_retval := string_list();

      loop

        --l_idx := instr(l_list,p_del);
        l_idx := my_instr(l_list,p_del);

        l_retval.extend;

        if l_idx > 0 then
          --pipe row(substr(l_list,1,l_idx-1));
          --l_list := substr(l_list,l_idx+length(p_del));
          l_retval(l_retval.count) := substr(l_list, 1, l_idx - 1);
          l_list := substr(l_list,l_idx+length(p_del));
        else
          --pipe row(l_list);
          --exit;
          l_retval(l_retval.count) := l_list;
          exit;
        end if;

      end loop;

      return l_retval;

    end split;