Trouble with ARRAYs - Mailing list pgsql-general

From Ralph Smith
Subject Trouble with ARRAYs
Date
Msg-id 4D817A25.6010903@10kinfo.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: Nick Rudnick
Date:
Subject: OT: Oleg Bartunov in Himalaya...
Next
From: Pavel Stehule
Date:
Subject: Re: query taking much longer since Postgres 8.4 upgrade