From: | Ralph Smith <rsmith(at)10kinfo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Trouble with ARRAYs |
Date: | 2011-03-17 03:04:05 |
Message-ID: | 4D817A25.6010903@10kinfo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
There seems to be inadequate info on filling arrays from a table, (vs
keyboarding), and
how to do a lookup in an array. I've tried to almost no avail.
- - - - - - -
I have a loop that I'm executing thousands of times and inside of it I have
SELECT INTO myvar column1 FROM mytable WHERE column2 =
somevalue ;
I'm trying to use an array lookup, ala this, that I found in the manual
ANY/SOME (array)
expression operator ANY (array expression)
But I'm a newbie to arrays, so I've tried
DECLARE myarray VARCHAR[] := array['''',''''] ;
then in the body
SELECT INTO myarray ARRAY[column1, column2] from mytable ;
I've discovered via trial and error that the above arrayification works
on a simple SQL query without variables.
How can I go about getting a simple variable out of that array on a
match on another column?
This query executing thousands of times is killing me!
Thanks,
Ralph
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2011-03-17 05:12:50 | Re: query taking much longer since Postgres 8.4 upgrade |
Previous Message | Nick Rudnick | 2011-03-16 23:45:54 | OT: Oleg Bartunov in Himalaya... |