why does documentation use "END CASE" when that doesn't work

Started by Susan Cassidyabout 12 years ago3 messagesgeneral
Jump to latest
#1Susan Cassidy
susan.cassidy@decisionsciencescorp.com

The documentation says:

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

And it repeats the "END CASE" phrase in other examples.

However, that doesn't work. You have to just use "END".

Shouldn't the documentation be fixed?

Susan

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Susan Cassidy (#1)
Re: why does documentation use "END CASE" when that doesn't work

Susan Cassidy <susan.cassidy@decisionsciencescorp.com> writes:

The documentation says:
CASE search-expression
WHEN expression [, expression [ ... ]] THEN
statements
[ WHEN expression [, expression [ ... ]] THEN
statements
... ]
[ ELSE
statements ]
END CASE;

And it repeats the "END CASE" phrase in other examples.

However, that doesn't work. You have to just use "END".

Shouldn't the documentation be fixed?

No ... you're confusing the SQL CASE expression with the plpgsql CASE
statement.

http://www.postgresql.org/docs/9.3/static/functions-conditional.html

http://www.postgresql.org/docs/9.3/static/plpgsql-control-structures.html#PLPGSQL-CONDITIONALS

It's a bit unfortunate that plpgsql's statement looks enough like the
expression to cause confusion, yet not exactly like the expression.
The decorated END is consistent with other things in plpgsql such as
END IF, though.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Jov
zhao6014@gmail.com
In reply to: Susan Cassidy (#1)
Re: why does documentation use "END CASE" when that doesn't work

plpgsql case use end case,while sql case use end,they are different language

jov
在 2014-2-26 上午8:32,"Susan Cassidy" <susan.cassidy@decisionsciencescorp.com

Show quoted text

写道:

The documentation says:

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

And it repeats the "END CASE" phrase in other examples.

However, that doesn't work. You have to just use "END".

Shouldn't the documentation be fixed?

Susan