caseExpressionItem

A single when/then branch within a case expression. The when expression is evaluated; if true (or equal to the case operand in a selected-case form), the then expression is returned as the result.

Examples

Boolean case branch

case
  when AgeInYears() < 2 then 'infant'
  when AgeInYears() < 18 then 'child'
  else 'adult'
end

Selected-case branch

case AgeInYears()
  when 0 then 'newborn'
  when 1 then 'one year old'
  else 'older'
end
Railroad Diagram
100%
when expression then expression

scroll to zoom · drag to pan · click green rules or blue tokens to navigate

EBNF

caseExpressionItem
  : 'when' expression 'then' expression
  ;

Used In