Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did something similiar to this in the past. You need to create a function that accepts an input string and a separator and returns a dataset. If separator is ommited, then comma is assumed.</p> <p>First create a new type that represents a table of strings:</p> <pre><code>create or replace type varcharTableType as table of varchar2(255); / </code></pre> <p>Then create this function:</p> <pre><code>create or replace function splitString( allValues in varchar2, delim in varchar2 default ',' ) return varcharTableType as str varchar2(255) := allValues || delim; pos number; dataset varcharTableType := varcharTableType(); begin loop pos := instr(str, delim); exit when (nvl(pos, 0) = 0); dataset.extend; dataset(dataset.count) := ltrim(rtrim(substr(str, 1, pos - 1))); str := substr(str, pos + length(delim)); end loop; return dataset; end; / </code></pre> <p>Finally, call as:</p> <pre><code>select * from table(cast(splitString('a,b,c') as varcharTableType)); COLUMN_VALUE --------------- a b c 3 rows selected </code></pre> <p>To answer your specific case, you simply need to create a view that joins your table with this function table, as: </p> <pre><code> create or replace view splitView as select yourTable.id, s.column_value as value from yourTable, table(cast(splitString(yourTable.value) as varcharTableType)) s; select * from splitView; id value ---- --------------- 1 a 1 b 1 c 3 rows selected </code></pre> <p>I am not sure if this last query will work, as I don't have an Oracle machine right now, but hopefully should help you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload