Shane. printf() will pad spaces you can replace with 'x' or whatever. WITH lengths(id,l) AS (VALUES (1,4),(2,1),(3,9)) SELECT id,l,replace(printf('%'||l||'s'),' ','x')mask FROM lengths; id,l,mask 1,4,xxxx 2,1,x 3,9,xxxxxxxxx
If printf() weren't available, it would be worth the effort to add your own extension function that does the exact thing efficiently. Extensions are extremely powerful. You can even write extensions to produce desired side effects. On Wed, Nov 22, 2017 at 1:56 PM, Shane Dev <devshan...@gmail.com> wrote: > Let's say I have a table of stringlengths - > > sqlite>select * from stringlengths; > length > 4 > 1 > 9 > ... > > Can I create a view xstrings containing strings (for example of char 'x') > with the lengths specified in stringlengths? > > desired result - > > sqlite>select * from xstrings; > string > xxxx > x > xxxxxxxx > ... > > P.S I know that substr('xxxxxxxxx', 1, stringlengths.length) would work in > this particular case but then I must know maximum value of > stringlengths.length at the point of time when I construct the query. Is > there a more flexible way? > > > .. > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users