Search Postgresql Archives

Re: Concatenating several rows with a semicolon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux