English | 简体中文

api-docs / org.ktorm.expression / CaseWhenExpression / <init>

<init>

CaseWhenExpression(
    operand: ScalarExpression<*>?,
    whenClauses: List<Pair<ScalarExpression<*>, ScalarExpression<T>>>,
    elseClause: ScalarExpression<T>?,
    sqlType: SqlType<T>,
    isLeafNode: Boolean = false,
    extraProperties: Map<String, Any> = emptyMap())

Case-when expression, represents a SQL case-when clause.

There are two kind of case-when clauses in SQL, one is simple case-when clause, which has an operand following
the case keyword, for example:

case operand when a then 1 when b then 2 else 3

The other is searched case-when clause, which doesn’t have an operand, for example:

case when a = 1 then 1 when b = 2 then 2 else 3

See the SQL BNF Grammar https://ronsavage.github.io/SQL/sql-2003-2.bnf.html#case%20expression