Re: using a selected row as a function parameter

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: using a selected row as a function parameter
Дата
Msg-id 5175.1117811748@sss.pgh.pa.us
обсуждение исходный текст
Ответ на using a selected row as a function parameter  (Ami Ganguli <ami.ganguli@gmail.com>)
Список pgsql-sql
Ami Ganguli <ami.ganguli@gmail.com> writes:
> SELECT queue.apply_routing_rule( 
>                       (SELECT * from queue.messages WHERE id = 1),
>                       (SELECT * from queue.routing_rules WHERE id = 1)
>                       );

Not sure if that particular syntax should be expected to work,
but why not

SELECT queue.apply_routing_rule(messages.*, routing_rules.*)
FROM queue.messages, queue.routing_rules
WHERE messages.id = 1 AND routing_rules.id = 1;

The query as you want to write it will certainly fail anyway if there's
more than one row with id = 1 in either table, so it's not like there's
some huge inefficiency in doing it as a join.
        regards, tom lane


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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: 'true'::TEXT::BOOLEAN
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: using a selected row as a function parameter