Skip Headers

# Understanding the Oracle SEQUENCE Object

Previous

Next

The Oracle `SEQUENCE` object implements a strategy that closely resembles TopLink sequencing: it implements an `INCREMENT` construct that parallels the TopLink preallocation size, and a `sequence.nextval` construct that parallels the `SEQ_COUNT` field in the TopLink `SEQUENCE` table in table sequencing. This implementation enables TopLink to use the Oracle `SEQUENCE` object as if it were a TopLink `SEQUENCE` table, but eliminates the need for TopLink to create and maintain the table.

As with table sequencing, TopLink creates a pool of available numbers by requesting that the Oracle `SEQUENCE` object increment the `sequence.nextval` and return the result. Oracle adds the value, `INCREMENT`, to the `sequence.nextval`, and TopLink uses the result to build the sequencing pool.

The key difference between this process and the process involved in table sequencing is that TopLink is unaware of the `INCREMENT` construct on the `SEQUENCE` object. TopLink sequencing and the Oracle `SEQUENCE` object operate in isolation. To avoid sequencing errors in the application, set the TopLink preallocation size and the Oracle `SEQUENCE` object `INCREMENT` to the same value. Note that the Oracle sequence object must have a starting value equal to the preallocation size because when TopLink gets the next sequence value, it assume it has the previous preallocation size of values.