Search Postgresql Archives

Re: Argument type list

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

 



Erik Jones <erik@xxxxxxxxxx> writes:
> On Aug 23, 2007, at 11:56 AM, Gustavo Tonini wrote:
>> I want to create a function that receive a list argument and filter
>> data with IN operator. Example:

> CREATE OR REPLACE FUNCTION public.ffoo(list sometype[]) RETURNS VOID  

this is right ...

>   execute 'select * from foo where foo_column::text in (' ||  
> array_to_string(list, ',') || ');';

this is pretty horrid.  Use = ANY(array) instead of trying to construct
an IN on the fly.

	select * from foo where foo_column = any(list)

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[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