Reputation: 177
Using Firebird 2.5, I want to create a generator that increments a column every 10 units instead of one by one. I couldn't find any reference to accomplish this in the Firebird documentation nor on the web.
Upvotes: 2
Views: 402
Reputation: 109239
When using next value for <sequence name>
with a sequence (generator), it can only increment by one (Firebird sequences do not have a configuration to specify a default increment of a larger value):
Each time the
NEXT VALUE FOR seq_name
operator is used with that sequence, its value increases by 1. TheGEN_ID(seq_name, <step>)
function can be called instead, to "step" the series by a different integer number.
This also points to a workaround: use the legacy gen_id
function with an increment larger than 1:
Increments a generator or sequence and returns its new value. From Firebird 2.0 onward, the SQL-compliant
NEXT VALUE FOR
syntax is preferred, except when an increment other than 1 is needed.
[..]
Syntax:GEN_ID (generator-name, <step>)
In other words: use GEN_ID(<sequence name>, 10)
to increment a sequence by 10 instead of 1.
Upvotes: 4