Reputation: 5
UPDATE table
SET field = REPLACE(your_field, 'original_string', 'replace_string')
WHERE your_field LIKE '%original_string%'
Is there a way I could execute above query with JOOQ?
Upvotes: 0
Views: 568
Reputation: 221106
Yes, it translates pretty much 1:1. Just write it out like this:
using(configuration)
.update(TABLE)
.set(TABLE.FIELD,
replace(TABLE.YOUR_FIELD, "original_string", "replace_string"))
.where(TABLE.YOUR_FIELD.like("%original_string%"))
.execute();
The DSL.replace()
method is documented in the Javadoc
import static org.jooq.impl.DSL.*;
import static com.example.your.schema.Tables.*;
Upvotes: 3