DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Erico has posted 5 posts at DZone. View Full User Profile

Função Oracle Que Realiza Um Split Para Criação De Clausulas 'IN'

09.13.2009
| 3050 views |
  • submit to reddit
        uso:  x.campo IN (SELECT COLUMN_VALUE FROM (TABLE(PKGL_UTIL.FNCL_SPLIT_STRING('1,2,3,4,5,6,7')))))  

 function FNCL_SPLIT_STRING
  (
      p_list varchar2,
      p_del varchar2 := ','
  ) return SPLIT_TBL pipelined
  is
      l_idx    pls_integer;
      l_list    varchar2(32767) := p_list;
  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 FNCL_SPLIT_STRING;