This is from the official documentation (http://www.postgresql.org/docs/9.4/static/plpgsql-control-structures.html)
and two forms of CASE:
CASE ... WHEN ... THEN ... ELSE ... END CASE
CASE WHEN ... THEN ... ELSE ... END CASE
select case when 1 < 2 then 'a' else 'b' end case from pg_database limit 1;
select case when 1 < 2 then 'a' else 'b' end from pg_database limit 1;
Both use the key word
CASE, but it's not the same thing.
CASE in PL/pgSQL is a control structure for the procedural language, while
CASE in SQL is a conditional expression.
You are not the first to be confused. There are other minor differences in the syntax. For instance, PL/pgSQL allows a list of values for the "simple
CASE" variant, which is not possible in SQL:
... WHEN expression [, expression [ ... ]] THEN
Would be nice to have in SQL as well, but the standard does allow it and Postgres sticks to the standard.