Re: using a selected row as a function parameter

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ami Ganguli <ami(dot)ganguli(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: using a selected row as a function parameter
Date: 2005-06-03 15:23:28
Message-ID: 20050603152328.GA66944@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-06-03 15:28:02 Re: 'true'::TEXT::BOOLEAN
Previous Message Tom Lane 2005-06-03 15:15:48 Re: using a selected row as a function parameter