How to Fetch Sequence Values with jOOQ

A lot of RDBMS support standard SQL sequences of some form. The standard SQL syntax to create a sequence is: CREATE SEQUENCE s; The following is how you could fetch a value from this sequence, using jOOQ, assuming you're using the code generator: // import static com.example.generated.Sequences.*; System.out.println(ctx.fetchValue(S.nextval())); The sequence expression translates to a variety … Continue reading How to Fetch Sequence Values with jOOQ

Don’t Forget to Set the SEQUENCE CACHE Size

In most cases, simply creating an Oracle SEQUENCE with all defaults is good enough: CREATE SEQUENCE my_sequence; This sequence can then be used immediately in triggers when inserting new records in a table: CREATE OR REPLACE TRIGGER my_trigger BEFORE INSERT ON my_table FOR EACH ROW -- Optionally restrict this trigger to -- fire only when … Continue reading Don’t Forget to Set the SEQUENCE CACHE Size