"Karl O. Pinc" <kop@meme.com> writes:
> begintest4() moves the declariation from the outermost BEGIN block
> to the inner BEGIN block, the one that's EXITed. It fails with:
> WARNING: plpgsql: ERROR during compile of begintest4 near line 9
> ERROR: syntax error at or near "some_label"
You're misreading the syntax. A <<label>> applies to a whole block
including any declarations. So instead of
> BEGIN
> DECLARE
> var INT;
> <<some_label>>
> BEGIN
> var := 5;
> EXIT some_label;
> var := 0;
> END;
> RETURN NULL;
> END;
write
> BEGIN
> <<some_label>>
> DECLARE
> var INT;
> BEGIN
> var := 5;
> EXIT some_label;
> var := 0;
> END;
> RETURN NULL;
> END;
See the definition of "block" at the very top of
http://developer.postgresql.org/docs/postgres/plpgsql-structure.html
...
regards, tom lane