Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJf5-000091-Cb for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Oct 2013 00:29:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VbJf4-00082q-Kv for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Oct 2013 00:29:26 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJf3-00082e-KS for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:29:25 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbJf0-00053m-LE for pgsql-bugs@postgresql.org; Wed, 30 Oct 2013 00:29:24 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VbJf0-0003p8-B2 for pgsql-bugs@postgresql.org; Tue, 29 Oct 2013 17:29:22 -0700 Date: Tue, 29 Oct 2013 17:29:22 -0700 (PDT) From: David Johnston To: pgsql-bugs@postgresql.org Message-ID: <1383092962118-5776318.post@n5.nabble.com> In-Reply-To: References: Subject: Re: BUG #8568: PLPGSQL Documentation For CASE Is incorrect MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 4.5 (++++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs