Re: Sub-query as function argument

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Sub-query as function argument
Дата
Msg-id 29178.1135091259@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Sub-query as function argument  (Michael Burke <michael@engtech.ca>)
Список pgsql-sql
Michael Burke <michael@engtech.ca> writes:
> Is it possible to execute a SELECT query as an argument to a function?

> SELECT my_func('Sample', NULL, SELECT MIN(year) FROM audio);

You need parentheses around the sub-SELECT.
 SELECT my_func('Sample', NULL, (SELECT MIN(year) FROM audio));

This is generally true everywhere in expressions, not just in
function arguments.  Without the parens, it's often ambiguous
what's subselect and what's outer query.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Querying date_time for date only ?
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Does VACUUM reorder tables on clustered indices