Subject RE: [firebird-support] Database Field Concatenate
Author Thomas Steinmaurer
Jacob,

> I have a result set from the following
> select petname where ownerid = 100674, the results will look like this
>
> JETHRO
> FLUFFY
> FOOFOO
>
> is there a method in firebird to turn these results into a concatonated
> list such as
> JETHRO, FLUFFY, FOOFOO
> My reporting software does not support this clientside so i have been
> looking for a solution server side (preferably through stored procedure)
> but i have been unable to find any way to accomplish this through a
> stored procedure.

You might get the idea with the following selectable
stored procedure:

SET TERM ^^ ;
CREATE PROCEDURE PRO_TEST returns (
RESULT VarChar(1024))
AS
declare variable name varchar(20);
begin
result = '';
for select name from test1 order by name into :name do
begin
if (result <> '') then
begin
result = result || ', ';
end
result = result || name;
end
suspend;
end
^^
SET TERM ; ^^


Use a *selectable* stored procedure like any table, with

SELECT * FROM PRO_TEST;


HTH,
Thomas