Re: Passing result of multirow subquery to C function
| От | Tom Lane |
|---|---|
| Тема | Re: Passing result of multirow subquery to C function |
| Дата | |
| Msg-id | 25595.1388507319@sss.pgh.pa.us обсуждение |
| Ответ на | Passing result of multirow subquery to C function (Magnus Persson <magnus.e.persson@gmail.com>) |
| Список | pgsql-novice |
Magnus Persson <magnus.e.persson@gmail.com> writes:
> What I'm having issues figuring out is how to pass the results of a
> subquery to a function (if at all possible?):
> SELECT hello((SELECT name FROM names));
There's no direct way to do that; we have a notion of a "function
returning set", but not one of a "function accepting set".
The most straightforward thing is to reinterpret the requirement
as
SELECT hello(name) FROM names;
so that the function just deals with one name at a time.
You could also give the query to the function as a string and
have it execute the query internally (using SPI):
SELECT hello('SELECT name FROM names');
I find this to be a pretty bad design choice most of the time,
but sometimes there's no good alternative. There are precedents
in core PG, such as the ts_stat() functions.
regards, tom lane
В списке pgsql-novice по дате отправления: