Subject | RE: [firebird-support] How can a stored procedure construct a string made up of multiple row data? |
---|---|
Author | Alan McDonald |
Post date | 2007-02-16T19:04:15Z |
> Dear forum members,DECLARE tmpcity VARCHAR(50);
>
> I have a column of unique cities. I would like to create a
> procedure, when executed returns a varchar containing all cities
> enclosed in brackets, for example:
>
> [Arlington][Beaumont][Chicago]
>
>
>
> CREATE PROCEDURE NEW_PROCEDURE
> returns (
> cities varchar(2000),
> as
> begin
> select city_tbl.city from city_tbl into :cities;
> suspend;
> end^
>
>
> In my procedure I get a singleton select error. I guess that if I
> knew how to traverse each record within the procedure, would be able
> to concatenate each city into the varchar.
>
> Thank you
> CREATE PROCEDURE NEW_PROCEDURE
> returns (
> cities varchar(2000),
> as
> begincities = '';
> FOR select city_tbl.city from city_tbl into :TMPCITY DO BEGINcities = :cities||'['||:tmpcity||']';
END
exit;
> end^Alan
PS this is terrible design.