Re: Trouble EXITing plpgsql labeled BEGIN blocks with DECLAREs

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Trouble EXITing plpgsql labeled BEGIN blocks with DECLAREs
Дата
Msg-id 27933.1095123100@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Trouble EXITing plpgsql labeled BEGIN blocks with DECLAREs  ("Karl O. Pinc" <kop@meme.com>)
Список pgsql-general
"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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Karl O. Pinc"
Дата:
Сообщение: Trouble EXITing plpgsql labeled BEGIN blocks with DECLAREs
Следующее
От: "Matthew T. O'Connor"
Дата:
Сообщение: Corrupted Data?