| From: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Cc: | "Marcin Krawczyk" <jankes(dot)mk(at)gmail(dot)com> |
| Subject: | Re: array variables |
| Date: | 2008-11-13 09:39:03 |
| Message-ID: | 200811131139.03872.achill@matrix.gatewaynet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Στις Thursday 13 November 2008 11:13:30 ο/η Marcin Krawczyk έγραψε:
> 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
how about smth like:
SELECT ARRAY[ARRAY(SELECT id FROM idx),ARRAY(SELECT p FROM idx)];
you will get 2 rows with "select count(*) from idx" columns each.
you can access it like
SELECT (ARRAY[ARRAY(SELECT id FROM idx),ARRAY(SELECT p FROM idx)])[i][j];
1<=i<=2
1<=j<=select count(*) from idx
>
> regards
> mk
>
--
Achilleas Mantzios
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marcin Krawczyk | 2008-11-13 09:44:01 | Re: array variables |
| Previous Message | Pavel Stehule | 2008-11-13 09:30:43 | Re: array variables |