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

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Events

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

Most dialects supporting triggers can fire ...

  • BEFORE
  • AFTER
  • INSTEAD OF

... a certain event, including ...

  • INSERT
  • UPDATE
  • DELETE

Note that the above refer to events, not the statements, meaning that a trigger may fire also for the MERGE statement.

Some examples illustrating possible triggers:

create.createTrigger("trg1")
      .beforeInsert()
      .on(BOOK)
      .forEachRow()
      .as(insertInto(LOG).columns(LOG.TEXT).values("Row inserted in BOOK"))
      .execute();

create.createTrigger("trg")
      .beforeUpdate()
      .on(BOOK)
      .forEachRow()
      .as(insertInto(LOG).columns(LOG.TEXT).values("Row updated in BOOK"))
      .execute();

create.createTrigger("trg")
      .beforeDelete()
      .on(BOOK)
      .forEachRow()
      .as(insertInto(LOG).columns(LOG.TEXT).values("Row deleted in BOOK"))
      .execute();

create.createTrigger("trg")
      .beforeInsert().orUpdate().orDelete()
      .on(BOOK)
      .forEachRow()
      .as(insertInto(LOG).columns(LOG.TEXT).values("Row inserted or updated or deleted in BOOK"))
      .execute();

References to this page

Feedback

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

The jOOQ Logo