Subject | Re: [firebird-support] Re: Implode |
---|---|
Author | Milan Babuskov |
Post date | 2004-01-26T14:49:30Z |
anzejbecan wrote:
create procedure implode
returns concat_string varchar(2000);
as
declare variable temp varchar(50);
declare variable first char(1);
begin
concat_string = '';
first = 'Y';
for select name from people
into :temp
do
begin
if (first = 'Y') then first = 'N';
else concat_string = concat_string || ', ';
concat_string = concat_string || temp;
end
suspend;
end
I hope this gives you some ideas.
--
Milan Babuskov
http://fbexport.sourceforge.net
> PHP function implode is just an example of what I want.Something like this should do it:
> As I said I want to join data from several rows (with only one column)
> into one single string (separated with some delimiter).
>
> For example if result of "select name from people" is:
> John
> Paul
> Linda
> ...
>
> The result I want is one string: "John, Paul, Linda".
create procedure implode
returns concat_string varchar(2000);
as
declare variable temp varchar(50);
declare variable first char(1);
begin
concat_string = '';
first = 'Y';
for select name from people
into :temp
do
begin
if (first = 'Y') then first = 'N';
else concat_string = concat_string || ', ';
concat_string = concat_string || temp;
end
suspend;
end
I hope this gives you some ideas.
--
Milan Babuskov
http://fbexport.sourceforge.net