wording for 38.6.2.4. Simple CASE and 38.6.2.5. Searched CASE

From: Andreas Wenk <a(dot)wenk(at)netzmeister-st-pauli(dot)de>
To: pgsql-docs(at)postgresql(dot)org
Subject: wording for 38.6.2.4. Simple CASE and 38.6.2.5. Searched CASE
Date: 2009-08-14 21:07:29
Message-ID: 4A85D211.8000604@netzmeister-st-pauli.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hi,

I find it a little confusing how 38.6.2.4. Simple CASE and 38.6.2.5.
Searched CASE is described. In Simple CASE is written

CASE search-expression
WHEN expression [,

and in 38.6.2.5. Searched CASE is written

CASE
WHEN boolean-expression

IMO speaking of a search-expression for the simple CASE and speaking of
a boolean-expression in between Searched Case is confusing because of
the use of the word "search". I would change it to that:

[snip]
38.6.2.4. Simple CASE

CASE
WHEN boolean-expression THEN
statements
[ WHEN boolean-expression THEN
statements
... ]
[ ELSE
statements ]
END CASE;

The simple form of CASE provides conditional execution based on truth of
boolean expressions. Each WHEN clause's boolean-expression is evaluated
in turn, until one is found that yields true. Then the corresponding
statements are executed, and then control passes to the next statement
after END CASE. (Subsequent WHEN expressions are not evaluated.) If no
true result is found, the ELSE statements are executed; but if ELSE is
not present, then a CASE_NOT_FOUND exception is raised.

[EXAMPLE ...]

38.6.2.5. Searched CASE

CASE search-expression
WHEN expression [, expression [ ... ]] THEN
statements
[ WHEN expression [, expression [ ... ]] THEN
statements
... ]
[ ELSE
statements ]
END CASE;

The searched form of CASE provides conditional execution based on
equality of operands. The search-expression is evaluated (once) and
successively compared to each expression in the WHEN clauses. If a match
is found, then the corresponding statements are executed, and then
control passes to the next statement after END CASE. (Subsequent WHEN
expressions are not evaluated.) If no match is found, the ELSE
statements are executed; but if ELSE is not present, then a
CASE_NOT_FOUND exception is raised.

[EXAMPLE ...]

[snip]

I moved 38.6.2.5 to 38.6.2.4 and changed the naming ...

Thoughts?

Cheers

Andy

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2009-08-14 21:18:20 Re: wording for 38.6.2.4. Simple CASE and 38.6.2.5. Searched CASE
Previous Message Josh Berkus 2009-08-08 01:00:48 pl/perl doc correction: subroutines