Re: array variables - Mailing list pgsql-sql

From Achilleas Mantzios
Subject Re: array variables
Date
Msg-id 200811131139.03872.achill@matrix.gatewaynet.com
Whole thread Raw
In response to Re: array variables  ("Marcin Krawczyk" <jankes.mk@gmail.com>)
List 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


pgsql-sql by date:

Previous
From: "Marcin Krawczyk"
Date:
Subject: Re: array variables
Next
From: Tom Lane
Date:
Subject: Re: array variables