how to convert csv to table in oracle

The following works invoke it as select * from table(splitter(‘a,b,c,d’)) create or replace function splitter(p_str in varchar2) return sys.odcivarchar2list is v_tab sys.odcivarchar2list:=new sys.odcivarchar2list(); begin with cte as (select level ind from dual connect by level <=regexp_count(p_str,’,’) +1 ) select regexp_substr(p_str,'[^,]+’,1,ind) bulk collect into v_tab from cte; return v_tab; end; /

Parse (split) a string in C++ using string delimiter (standard C++)

You can use the std::string::find() function to find the position of your string delimiter, then use std::string::substr() to get a token. Example: std::string s = “scott>=tiger”; std::string delimiter = “>=”; std::string token = s.substr(0, s.find(delimiter)); // token is “scott” The find(const string& str, size_t pos = 0) function returns the position of the first occurrence … Read more

Splitting string into multiple rows in Oracle

This may be an improved way (also with regexp and connect by): with temp as ( select 108 Name, ‘test’ Project, ‘Err1, Err2, Err3’ Error from dual union all select 109, ‘test2’, ‘Err1’ from dual ) select distinct t.name, t.project, trim(regexp_substr(t.error, ‘[^,]+’, 1, levels.column_value)) as error from temp t, table(cast(multiset(select level from dual connect by … Read more