Subject RE: [firebird-support] How to add empty space into between characters in string?
Author Svein Erling Tysvær
What about

With Recursive CommaMe(WithComma, WithoutComma)
(select cast('' as VarChar(255)), 'ABCD'
from rdb$database
union all
select WithComma || ',' || substring(WithoutComma from 1 for 1),
substring(WithoutComma from 2 for 255)
from CommaMe
where WithoutComma > '')

select max(WithComma)
from CommaMe

Though looking at the SQL above, it might be simpler to use a stored procedure.

And I haven't tested whether the above SQL works (or contains syntax errors) or whether you could replace 'ABCD' with a parameter. The level of recursion is somewhat limited in Firebird (I don't remember how deep recursion can be), so don't expect it to work if you have strings with 30000 characters.


-----Original Message-----
From: [] On Behalf Of Le Phuc
Sent: 2. september 2009 16:53
Subject: RE: [firebird-support] How to add empty space into between characters in string?

Thanks, but string’s length not fixed.

Mr. Lê Phúc


> Hi all, I use FB 2.1.3 RC2, I have a string(Ex: ABCD), I want to add an
>empty space(or an character ‘,’) between each characters in string. Please
>send me what function or SQL code.


select substring(yourfield from 1 for 1)||','||substring(yourfield from 2
for 1) from yourtable