Vai al contenuto

# STRING_TO_TABLE_ENUM

## Codice Sorgente

`sql FUNCTION "STRING_TO_TABLE_ENUM" (p_string VARCHAR2, v_level in number default 0, p_separator varchar2 default ':') RETURN ENUM_TABLE_TYPE pipelined IS conta number := 0; BEGIN FOR c IN ( select ROW_NUMBER() OVER (ORDER BY ROWNUM) id, result from ( with test as ( select p_string col from dual ) select nvl(regexp_substr(col, '[^' || p_separator || ']+', 1, level), '') result from test connect by level <= length(regexp_replace(col, '[^' || p_separator || ']+')) + 1) ) LOOP conta := conta + 1; if v_level = 0 or ( v_level = conta ) then pipe row(enum_table_object(c.id,c.result)); end if; END LOOP; RETURN; END STRING_TO_TABLE_ENUM;`