From: David Johnston <polobo@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
Date: Tue, 29 Oct 2013 17:29:22 -0700 (PDT)
Message-ID: <1383092962118-5776318.post@n5.nabble.com> (raw)
In-Reply-To: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org>
References: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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-tp57763...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: polobo@yahoo.com
Subject: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect
In-Reply-To: <1383092962118-5776318.post@n5.nabble.com>
References: <E1VbJJx-0003T6-KN@wrigleys.postgresql.org> <1383092962118-5776318.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox