Available in versions: Dev (3.18)

This is experimental functionality, and as such subject to change. Use at your own risk!

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

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