On 03/04/2014 11:23 AM, Joel Jacobson wrote:
> I understand that from a technical perspective, the mandatory
> BEGIN...END you always need in a PL/pgSQL function, is a new block,
> and the variables declared are perhaps technically in a new block, at
> a deeper level than the IN/OUT variables. But I would still argue the
> expected behaviour of PL/pgSQL for a new user would be to consider the
> IN/OUT variables to be in the same block as the variables declared in
> the function's first block.
>
No they are not. Teaching a new user to consider them as the same is
simply wrong.
The parameters belong to a block that matches the function name. The
outermost block has a different name if supplied (I usually use <<fn>>),
or is otherwise anonymous. Lots of code quite correctly relies on this,
including some I have written.
This isn't a mere technical difference, and there is surely zero chance
that we will label use of it an error under any circumstances.
cheers
andrew