Search Postgresql Archives

Trouble with ARRAYs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux