Re: Concatenating several rows with a semicolon

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Concatenating several rows with a semicolon
Date: 2010-12-28 19:25:28
Message-ID: AANLkTi=1KRe60dKYVOMrHN49xXE-y2Q+C4UVFesvtwR3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm trying:

create or replace function pref_money_stats(_id varchar)
returns varchar as $BODY$
begin

declare stats varchar;

for row in select yw, money from pref_money where id=_id order
by yw desc limit 20 loop
stats := stats || ";" || row.id || ":" || row.money;
end loop;

return stats;
end;
$BODY$ language plpgsql;

but get the error:

ERROR: syntax error at or near "for"
LINE 7: for row in select yw, money from pref_money where id...
^

Regards
Alex

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gary Chambers 2010-12-28 19:32:44 Re: Concatenating several rows with a semicolon
Previous Message Gurjeet Singh 2010-12-28 16:54:37 Re: Devart ADO.NET Data Providers Deliver Advanced Model-First and Database-First Support and Improved ORM Solution!