Search Postgresql Archives

Re: set returning function with variable argument - possible?

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

 



Hello

I don't know if I understand well, but you can do

select (f).* from (select f(var) from xtable where ...) x;

Regards

Pavel Stehule

2011/6/16 Frank Miles <fpm@xxxxxxxxxxxxxxxx>:
> I have a function that returns a set of a defined type, something like:
>
> Â Â Â ÂCREATE OR REPLACE FUNCTION f(arg) RETURNS SETOF return_type AS $$
> Â Â Â Â Â Â Â Â...
> Â Â Â Â$$ LANGUAGE 'plpgsql' STABLE with (isstrict);
>
> Ordinarily this function is called:
>
> Â Â Â ÂSELECT * FROM f(constant);
>
> But what I want to do is more like:
> Â Â Â ÂSELECT * FROM f(var) WHERE var IN (SELECT var FROM xtable WHERE ...);
>
> This fails, as does
> Â Â Â ÂSELECT * FROM f(var) WHERE var IN (constant);
>
> ->> Is there some syntax that will allow me to perform this operation?
>
> Note that there are differing ways for "arg" to be determined, so I'd rather
> not
> merge this operation into f() - I would have to have a number of f()'s, each
> with
> its own mechanism for developing its "arg"s.
>
> -------------
> Running Postgresql 8.4.7 on Debian 'squeeze'.
>
> Thanks for any pointers to documentation that I have overlooked in my
> search!
>
> Â Â Â Â-f
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

-- 
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