Lists: | pgsql-sql |
---|
From: | Leo Fink <leo(dot)fink(at)gmx(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Array of Arrays of int |
Date: | 2005-05-02 03:50:37 |
Message-ID: | 178c0af58f0514c54835d2e0723c525a@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Why does
select array(select array[1,2]);
give me an error: "could not find array type for data type integer[]"?
Is there a type-cast missing, or is this generally impossible? I was
expecting something like
{{1,2}}
In my real-world application, the subquery returns more than one pair
of ints, but I think it all boils down to this simpler example. I am
using version 7.4 of PostgreSQL.
Thanks a lot,
Leo
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Leo Fink <leo(dot)fink(at)gmx(dot)net> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Array of Arrays of int |
Date: | 2005-05-02 04:11:06 |
Message-ID: | 10431.1115007066@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Leo Fink <leo(dot)fink(at)gmx(dot)net> writes:
> Why does
> select array(select array[1,2]);
> give me an error: "could not find array type for data type integer[]"?
We don't do arrays of arrays. You seem to be hoping for a 2-D array,
which is something fundamentally different (even though some programming
languages consider them the same ;-))
regards, tom lane
From: | Leo Fink <leo(dot)fink(at)gmx(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Array of Arrays of int |
Date: | 2005-05-02 04:26:28 |
Message-ID: | 60948b9fc1ee07c0f106ed4585a08f84@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Hello Tom.
Am 02.05.2005 um 06:11 schrieb Tom Lane:
> Leo Fink <leo(dot)fink(at)gmx(dot)net> writes:
>> Why does
>> select array(select array[1,2]);
>> give me an error: "could not find array type for data type integer[]"?
>
> We don't do arrays of arrays. You seem to be hoping for a 2-D array,
> which is something fundamentally different (even though some
> programming
> languages consider them the same ;-))
Actually, I don't. In my application I can work around the problem by
using an array of string representations of these pairs, or by using
two arrays of ints. I just thought that was less elegant and I was
missing something obvious.
Thanks for your quick response.
Best,
Leo