Trouble with ARRAYs

Поиск
Список
Период
Сортировка
От Ralph Smith
Тема Trouble with ARRAYs
Дата
Msg-id 4D817A25.6010903@10kinfo.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Nick Rudnick
Дата:
Сообщение: OT: Oleg Bartunov in Himalaya...
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: query taking much longer since Postgres 8.4 upgrade