I have a list of records and I need to insert it in one query with upsert like
INSERT INTO table1 (name, lastname)
VALUES ('name1', 'lastname1'), ('name2', 'lastname2')
ON CONFLICT DO NOTHING;
Not batch or merge and necessary with 'on conflict' logic
Use the new jOOQ 3.15 InsertValuesStep2.valuesOfRows()
:
insertInto(table1, table1.name, table1.lastname)
.valuesOfRows(usersForInsert.map { DSL.row(it.name, it.lastname) })
.onConflictDoNothing()
.execute()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With