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

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: 42601 you

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 column SQL

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 enough to have

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 type, not

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 in 8.3. - and result

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 --- that's not

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. Sure you can, if

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 record You left out

[SQL] array variables in pl/pgsql

2001-09-14 Thread Jack
Is there any sample to show how to use array variable in PL/pgsql? How do I get an array from a table and do a loop to manipulate every element in that array? jack ---(end of broadcast)--- TIP 2: you can get off all lists at once with the