Re: [SQL] array variables

2008-11-13 Thread Pavel Stehule
2008/11/13 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> 2008/11/13 Tom Lane <[EMAIL PROTECTED]>: >>> My example was done in 8.3. > >> I tested it with error: > >> postgres=# select array(select row(a,b) from f); >> ERROR: could not find array type for datatype rec

Re: [SQL] array variables

2008-11-13 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > 2008/11/13 Tom Lane <[EMAIL PROTECTED]>: >> My example was done in 8.3. > I tested it with error: > postgres=# select array(select row(a,b) from f); > ERROR: could not find array type for datatype record You left out the cast to a named rowtype ---

Re: [SQL] array variables

2008-11-13 Thread Pavel Stehule
2008/11/13 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> 2008/11/13 Tom Lane <[EMAIL PROTECTED]>: >>> Sure you can, if you're using a version new enough to have arrays of >>> composite types. > >> I don't expect so user use devel version ;) > > My example was done i

Re: [SQL] array variables

2008-11-13 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > 2008/11/13 Tom Lane <[EMAIL PROTECTED]>: >> Sure you can, if you're using a version new enough to have arrays of >> composite types. > I don't expect so user use devel version ;) My example was done in 8.3. > - and result is array of > some composite

Re: [SQL] array variables

2008-11-13 Thread Pavel Stehule
2008/11/13 Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: >> 2008/11/13 Marcin Krawczyk <[EMAIL PROTECTED]>: >>> Because if I try this : >>> a := ARRAY(SELECT id, p FROM idx); >>> I get >>> ERROR: subquery must return only one column > >> you can't do it directly :( now

Re: [SQL] array variables

2008-11-13 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > 2008/11/13 Marcin Krawczyk <[EMAIL PROTECTED]>: >> Because if I try this : >> a := ARRAY(SELECT id, p FROM idx); >> I get >> ERROR: subquery must return only one column > you can't do it directly :( now. Sure you can, if you're using a version new eno

Re: [SQL] array variables

2008-11-13 Thread Achilleas Mantzios
Στις 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 co

Re: [SQL] array variables

2008-11-13 Thread Marcin Krawczyk
Thank you guys, I appreciate your help. regards mk

Re: [SQL] array variables

2008-11-13 Thread Pavel Stehule
Hello 2008/11/13 Marcin Krawczyk <[EMAIL PROTECTED]>: > 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:

Re: [SQL] array variables

2008-11-13 Thread 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 regards mk

[SQL] array variables

2008-11-13 Thread Marcin Krawczyk
Hi all. Can anyone help me solve this problem ? Say I have something like this: CREATE TEMP TABLE idx (id integer, p integer, idd integer); INSERT INTO idx (id, p, idd) VALUES (3048, 1, 12043); INSERT INTO idx (id, p, idd) VALUES (3048, 2, 2321); INSERT INTO idx (id, p, idd) VALUES (3048, 5, 12002