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

From Michael Fuhr
Subject Re: using a selected row as a function parameter
Date
Msg-id 20050603152328.GA66944@winnie.fuhr.org
Whole thread Raw
In response to using a selected row as a function parameter  (Ami Ganguli <ami.ganguli@gmail.com>)
List pgsql-sql
On Fri, Jun 03, 2005 at 05:44:59PM +0300, Ami Ganguli wrote:
>
> 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".

The error I get is "subquery must return only one column".  Queries
like the following should work in 8.0.x:

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

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

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: using a selected row as a function parameter
Next
From: Tom Lane
Date:
Subject: Re: 'true'::TEXT::BOOLEAN