Search Postgresql Archives

Array to IN or UNION

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

 



I'm doing a procedure and I'm trying to pass a dynamic array into a CURSOR, I found the sentence ANY but it's really slow. Is there any way to convert all the elements in this array to IN condition or one select with unions?
For example,

BEGIN
  example CURSOR (codes integer[] )
   SELECT *
   FROM table_1
    WHERE code IN (3,5,7)

or

  example CURSOR (codes integer[] )
   SELECT *
   FROM table_1
    WHERE codi = 3
   UNION
   SELECT *
   FROM table_1
    WHERE codi = 5
   SELECT *
   FROM table_1
    WHERE codi = 7


DECLARE

  OPEN example(ARRAY[3,5,7]);
END;



[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