7.6.4. Other Types of Queries
We’ll take a look at other types of queries. This query inserts a record:
INSERT INTO AUTHOR
(ID, FIRST_NAME, LAST_NAME)
VALUES (100, 'Hermann', 'Hesse');
In jOOQ:
dsl.insertInto(AUTHOR,
AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.values(100, "Hermann", "Hesse")
.execute();
A query to update a record:
UPDATE AUTHOR
SET FIRST_NAME = 'Hermann',
LAST_NAME = 'Hesse'
WHERE ID = 3;
In jOOQ:
dsl.update(AUTHOR)
.set(AUTHOR.FIRST_NAME, "Hermann")
.set(AUTHOR.LAST_NAME, "Hesse")
.where(AUTHOR.ID.equal(3))
.execute();
A query to delete a record:
DELETE FROM AUTHOR
WHERE ID = 100;
In jOOQ:
dsl.delete(AUTHOR)
.where(AUTHOR.ID.equal(100))
.execute();
More complex update queries can be built in jOOQ, such as a MERGE
query, for example.