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

STATEMENT vs ROW triggers

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

A trigger can choose whether it fires only once for entire sets of data being changed (FOR EACH STATEMENT), or for each individual row (FOR EACH ROW). The specific semantics of each of these clauses, and what's possible to do with each is vendor specific. Please refer to your database manual to see what's possible here.

An example of such triggers:

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

create.createTrigger("trg")
      .beforeInsert()
      .on(BOOK)
      .forEachStatement()
      .as(insertInto(LOG).columns(LOG.TEXT).values("Rows inserted in BOOK"))
      .execute();

Feedback

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

The jOOQ Logo