SQLite Forum

[Feature Request] split string table-valued function
Login
Thank you Ryan!

Apart from some renaming, for clarity;  
adding the index in the space-separated-list;   
and not having your `vLength` column, this is basically your code.


```
create view grids(parent, files) as ...

with
grid (parent, head, tail, idx) as
(
    select parent, '', files||' ', 0
      from grids
     UNION ALL
    select parent,
           trim(substr(tail, 1, instr(tail, ' ')-1)) as head,
           substr( tail, instr( tail, ' ' ) + 1) as tail,
           idx + 1 as idx
      from grid
     where instr(tail, ' ') > 0
)
select distinct parent, head as file, idx
  from grid
 where length(trim(head)) > 0
 order by parent, idx, file
```