# When

fun When(cond: Expression<T>, result: Expression<R>): ValueCaseWhen<T, R>

Adds a WHEN clause that compares against an expression condition.

#### Return

This ValueCaseWhen instance for method chaining

#### Parameters

cond

The expression to compare the case value against

result

The expression to return if the condition matches

fun When(cond: T, result: Expression<R>): ValueCaseWhen<T, R>

Adds a WHEN clause that compares against a literal condition.

#### Return

This ValueCaseWhen instance for method chaining

#### Parameters

cond

The literal value to compare the case value against

result

The expression to return if the condition matches

fun When(cond: Expression<T>, result: R, resultType: IColumnType<R & Any>? = null): ValueCaseWhen<T, R>

Adds a WHEN clause that compares against an expression condition with a literal result.

If the result isn't an Expression, it should be automatically converted to one behind the scenes. This requires providing an `IColumnType` for that value. That is needed only once at the start of the chain - after that, the column type value gets saved and reused for subsequent results.

#### Return

This ValueCaseWhen instance for method chaining

#### Parameters

cond

The expression to compare the case value against

result

The literal value to return if the condition matches

resultType

Optional column type for the result value

fun When(cond: T, result: R, resultType: IColumnType<R & Any>? = null): ValueCaseWhen<T, R>

Adds a WHEN clause that compares against a literal condition with a literal result.

#### Return

This ValueCaseWhen instance for method chaining

#### Parameters

cond

The literal value to compare the case value against

result

The literal value to return if the condition matches

resultType

Optional column type for the result value