Search Postgresql Archives

Re: variadic function, query "in", help with syntax/function

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

 



On Oct 21, 2012, at 11:01 AM, Pavel Stehule wrote:

> Hello
> 
> 2012/10/21 Scott Ribe <scott_ribe@xxxxxxxxxxxxxxxx>:
>> Briefly, what would it take to make the following work?
>> 
>> create function getbatch (variadic ids int8[]) returns setof foobar as $$
>> begin
>>        return query
>>                select * from foobar where id in (ids);
>> end;
>> $$ language plpgsql;
>> 
> 
> create function getbatch (variadic ids int8[]) returns setof foobar as $$
> begin
>        return query
>                select * from foobar where id = any (ids);
> end;
> $$ language plpgsql;

Ah, thanks, I didn't know any worked in that context--I've just used it (and only seen examples) the other way: const_id = any(somecol).

> note, for these single statement function, sql language is better

I greatly simplified it for the question; it's kind of a nasty function that's multiple unions of multiple joins.

-- 
Scott Ribe
scott_ribe@xxxxxxxxxxxxxxxx
http://www.elevated-dev.com/
(303) 722-0567 voice






-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[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