Re: Sub-query as function argument - Mailing list pgsql-sql

From Tom Lane
Subject Re: Sub-query as function argument
Date
Msg-id 29178.1135091259@sss.pgh.pa.us
Whole thread Raw
In response to Sub-query as function argument  (Michael Burke <michael@engtech.ca>)
List pgsql-sql
Michael Burke <michael@engtech.ca> writes:
> Is it possible to execute a SELECT query as an argument to a function?

> SELECT my_func('Sample', NULL, SELECT MIN(year) FROM audio);

You need parentheses around the sub-SELECT.
 SELECT my_func('Sample', NULL, (SELECT MIN(year) FROM audio));

This is generally true everywhere in expressions, not just in
function arguments.  Without the parens, it's often ambiguous
what's subselect and what's outer query.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Querying date_time for date only ?
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Does VACUUM reorder tables on clustered indices