Michael Burke <michael(at)engtech(dot)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