Sets a new value for an existing generator. Available in
gpre, DSQL, and
SET GENERATOR name TO <int>;
Name of an existing generator
Value to which to set the generator, an integer from –263 to 263 – 1
SET GENERATOR initializes a starting value for a newly created generator, or resets the value of an existing generator. A generator provides a unique, sequential numeric value through the
GEN_ID() function. If a newly created generator is not initialized with
GENERATOR, its starting value defaults to zero.
<int> is the new value for the generator. When the
GEN_ID() function inserts or updates a value in a column, that value is <int> plus the increment specified in the
GEN_ID()step parameter. Any value that can be stored in a DECIMAL(18,0) can be specified as the value in a SET GENERATOR statement.
Generators return a 64-bit value, and wrap around only after 264 invocations (assuming an increment of 1). Use an ISC-INT64 variable to hold the value returned by a generator.
Example: The following
isql statement sets a generator value to 1,000:
SET GENERATOR CUST_NO_GEN TO 1000;
GEN_ID() now calls this generator with a step value of 1, the first number it returns is 1,001.