set returning function with variable argument - possible?

From: Frank Miles <fpm(at)u(dot)washington(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: set returning function with variable argument - possible?
Date: 2011-06-16 04:18:08
Message-ID: alpine.LRH.2.01.1106152101380.20501@homer03.u.washington.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-06-16 04:46:13 Re: You could be a PostgreSQL Patch Reviewer!
Previous Message Craig Ringer 2011-06-16 04:14:13 Re: You could be a PostgreSQL Patch Reviewer!