Hello,
I have the following query
select substr(e.ename, iter.pos, 1) as C
from (select 'KING' as ename from dual) e,
(select rownum as pos from dictionary where rownum <= 100) iter
where iter.pos <= length(e.ename);
which outputs (as desired):
C
-
K
I
N
G
Hardcoding "KING" was done for testing purposes, IRL it would be a column from some table. The other piece that is hardcoded is "where rownum <= 100" and that is the one I'd like to find a way to remove.
I tried the following:
select substr(e.ename, iter.pos, 1) as C
from (select 'KING' as ename from dual) e,
(select rownum as pos from dictionary where rownum <= length(e.ename)) iter
where iter.pos <= length(e.ename);
unfortunately that doesn't work because the SQL parser has not parsed enough of the FROM clause to be aware of e.ename causing the expression length(e.ename) to return an unknown identifier message.
I've been trying to restructure the above query to make the SQL parser aware of e.ename early enough and thus accept it. My efforts have failed.
I'd like to know if there is a way to restructure the statement so length(e.ename) can be used instead of hardcoding an artificial upper limit (such as 100 as in the first statement).
Thank you,
John.