From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | David Johnston <polobo(at)yahoo(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect |
Date: | 2013-10-30 03:18:31 |
Message-ID: | CAFj8pRCiZn63UuBoADXWxCVVdFCDvt1jwO6_dQStuaK9NdMJag@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Dne 30.10.2013 1:29 "David Johnston" <polobo(at)yahoo(dot)com> napsal(a):
>
> 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.
It is just wrong. Plpgsql statements cannot be nested inside expression.
Plpgsql doesn't know only expression statemenst yet, so first token is
statement reserved keyword ever.
>
> 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.
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2013-10-30 14:13:37 | Re: BUG #8524: PQsendQueryParams with RETURNING clause on a INSERT |
Previous Message | fanjing09 | 2013-10-30 02:29:56 | BUG #8569: with recursive work incorrectly with function |