0
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?

1 Answer 1

3

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

The following static imports are assumed:

import static org.jooq.impl.DSL.*;
import static com.example.your.schema.Tables.*;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.