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

ARRAY_REPLACE

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

The ARRAY_REPLACE function allows for replacing all occurrences of an element by another value in an array:

SELECT array_replace(ARRAY[1, 2, 2, 3], 2, -1)
create.select(arrayReplace(array(1, 2, 2, 3), val(2), val(-1))).fetch();

The result would look like this:

+----------------+
| array_replace  |
+----------------+
| [1, -1, -1, 3] |
+----------------+
arrayReplace(array(1, 2, 2, 3), val(2), val(-1))

Feedback

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

The jOOQ Logo