Re: Case clause doesn't report syntactic error
Re: Case clause doesn't report syntactic error
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Leo Volin writes:
> This generates no error:
> select case '4'::int when 1 then 1 when 4 then 11 else 2 end;
> (prints 11)
> It doesn't match the documented format:
> CASE WHEN condition THEN result
> [WHEN ...]
> [ELSE result]
> END
You need to read down a couple of paragraphs to where the
"simple" variant of CASE is explained [1]:
CASE expression
WHEN value THEN result
[WHEN ...]
[ELSE result]
END
Perhaps we should rearrange that page so both syntax variants
appear at the top; but it's not wrong.
regards, tom lane
[1] https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-CASE