Re: using a selected row as a function parameter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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:15:48
Message-ID: 5175.1117811748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ami Ganguli <ami(dot)ganguli(at)gmail(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-06-03 15:23:28 Re: using a selected row as a function parameter
Previous Message Bruno Wolff III 2005-06-03 15:11:25 Re: 'true'::TEXT::BOOLEAN