On Wed, Aug 03, 2005 at 09:40:26AM -0400, Kevin Murphy wrote:
> You have to wrap a scalar subquery in its own parentheses even where you
> might think it to be unnecessary, such as when the subquery is the sole
> argument to a function.
It first guess I imagine it is because the syntax becomes ambiguous,
expecially if you have multiple arguments to the function.
Say you a function "func" and your query was: SELECT * FROM x ORDER BY y
Then this isn't parsable obviously:
SELECT func( SELECT * FROM x ORDER BY y, 1, 1 ) )
Since you don't know where the ORDER BY ends and the function list
continues. Adding parenthesis at the appropriate point removes the
ambiguity.
Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.