Available in versions: Dev (3.20) | Latest (3.19) | 3.18

Merge CASE .. WHEN clauses

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

When a searched CASE expression contains consecutive WHEN clauses returning the same value, then those WHEN clauses can be merged.

Using Settings.transformPatternsCaseMergeWhenWhen, the following transformations can be achieved:

-- With Settings.transformPatternsCaseMergeWhenWhen active, this:
SELECT
  CASE
    WHEN a = b THEN 1
    WHEN c = d THEN 1
  END
FROM tab;

-- ... is transformed into the equivalent expression:
SELECT
  CASE
    WHEN a = b OR c = d THEN 1
  END
FROM tab;

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo