Re: Function use in query

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Function use in query
Дата
Msg-id 1370466844313-5758066.post@n5.nabble.com
обсуждение исходный текст
Ответ на Function use in query  (Ioana Danes <ioanasoftware@yahoo.ca>)
Ответы Re: Function use in query  (Ioana Danes <ioanasoftware@yahoo.ca>)
Список pgsql-general
Ioana Danes wrote
> Hi All,
> Is there any similar syntax that only invokes the procedure once and
> returns all the columns?

Generic, adapt to fit your needs.


WITH func_call AS (
SELECT function_call(...) AS func_out_col
)
SELECT (func_out_col).*
FROM func_call;

Basically you have to execute the function call and leave the result as a
single column (a row type).  Then, in another layer of the query, you expand
that single column into its components using "*".  Because you are expanding
a column and not a table you must put the column name in "()" - otherwise
the parser thinks "func_out_col" is a table and errors out.

This all definitely applies to 9.2 and earlier.  9.3 (with lateral) may
behave differently...

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/Function-use-in-query-tp5758051p5758066.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Trouble with replication
Следующее
От: David Greco
Дата:
Сообщение: Re: Trouble with replication