Hello
2008/11/13 Marcin Krawczyk <jankes.mk@gmail.com>:
> I know I can do one column like this :
>
> a := ARRAY(SELECT id FROM idx);
>
> but how about more than one ?
> Because if I try this :
>
> a := ARRAY(SELECT id, p FROM idx);
>
> I get
> ERROR: subquery must return only one column
> SQL state: 42601
>
you can't do it directly :( now.
postgres=# create or replace function accum() returns int[] as
$$declare s int[] = '{}'; r record; begin for r in select * from f2
loop s := s || array[[r.a, r.b]]; end loop; return s; end;$$ language
plpgsql;
\CREATE FUNCTION
postgres=# select accum(); accum
-------------------{{10,10},{20,20}}
(1 row)
postgres=# select * from f2;a | b
----+----10 | 1020 | 20
(2 rows)
regards
Pavel Stehule
> regards
> mk
>