using a selected row as a function parameter

Поиск
Список
Период
Сортировка
От Ami Ganguli
Тема using a selected row as a function parameter
Дата
Msg-id 87eeecff0506030744e04eb25@mail.gmail.com
обсуждение исходный текст
Ответы Re: using a selected row as a function parameter
Re: using a selected row as a function parameter
Список pgsql-sql
Hi all,

I've been struggling with this for a while and haven't found anything
on the 'Net about it.  I've created a function that takes two table
rows as a parameters.  I'd like to use the output of a select (two
single rows) as the parameters, but I can't get it to work.  What am I
missing?

The function prototype looks like this:

CREATE OR REPLACE FUNCTION queue.apply_routing_rule(                      queue.messages,
queue.routing_rules                     ) RETURNS int2 

and I would like to call it like this:

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

I get an error message along the lines of "sub-query must return a
single value".  I've tried different combinations of "CAST" and "ROW"
functions, but they give syntax errors.

Any suggestions?

Regards,
Ami.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: CASE WHEN foo IS NULL THEN DEFAULT ELSE foo END
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: 'true'::TEXT::BOOLEAN