Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
Дата
Msg-id 1383092962118-5776318.post@n5.nabble.com
обсуждение исходный текст
Ответ на BUG #8568: PLPGSQL Documentation For CASE Is incorrect  (joshuadburns@hotmail.com)
Ответы Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-bugs
joshuadburns wrote
> Every example within the PLPGSQL "control structures" documentation states
> that the proper syntax for closing a "CASE" statement is to use "END
> CASE;"
> however in reality, on every version of PostgreSQL I can my hands on, "END
> CASE;" throws the following exception:

User error, though understandable.

pl/pgsql CASE requires "END CASE", SQL CASE just uses "END"

DO $$
DECLARE val integer;
BEGIN
val := 2;

CASE val
WHEN 1 THEN RAISE NOTICE 'Got 1';
WHEN 2 THEN RAISE NOTICE 'Got 2';
END CASE;

END;
$$;

Your examples were making use of SQL "CASE" expressions which do not accept
"END CASE" but "END".

A pl/pgsql CASE must be the first token of an expression (using the term
loosely) since its purpose is to act as flow-control.  The sames goes for
IF.

There are a number of constructs and keywords in pl/pgsql that behave
slightly differently than their counter-parts in pure SQL.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/BUG-8568-PLPGSQL-Documentation-For-CASE-Is-incorrect-tp5776314p5776318.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect