Re: using a selected row as a function parameter - Mailing list pgsql-sql

From Tom Lane
Subject Re: using a selected row as a function parameter
Date
Msg-id 5175.1117811748@sss.pgh.pa.us
Whole thread Raw
In response to using a selected row as a function parameter  (Ami Ganguli <ami.ganguli@gmail.com>)
List 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 by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: 'true'::TEXT::BOOLEAN
Next
From: Michael Fuhr
Date:
Subject: Re: using a selected row as a function parameter