On 2/1/07, Tom Lane <[EMAIL PROTECTED]> wrote:
imad <[EMAIL PROTECTED]> writes:
> OK, so renaming does not work in the same block.
> You can rename a vairable in a nested block and thats why it works for
> BTW, what is the purpose behind it? Declaring a variable in a block
> and quickly renaming it does not make sense to me.
I agree it's pretty useless; but if we're gonna forbid it then we should
throw a more sensible error than "syntax error".
Actually, it seems to me that it works in the nested-block case only for
rather small values of "work":
regression=# create function foo() returns int as $$
regression$# x int := 1;
regression$# x := 2;
regression$# rename x to y;
regression$# y := 3;
regression$# return x;
regression$# end$$ language plpgsql;
regression=# select foo();
ERROR: column "x" does not exist
LINE 1: SELECT x
QUERY: SELECT x
CONTEXT: PL/pgSQL function "foo" line 10 at return
Surely the variable's name should be x again after we're out of the
Yes, seems to be the only possible reason of renaming a variable.
---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at