Setting or Resetting Generator Values
From InterBase
Go Up to Working with Generators
SET GENERATOR
sets a starting value for a newly created generator, or resets the value of an existing generator. The new value for the generator, <int>, can be an integer from –263 to 263– 1. When the GEN_ID()
function is called, that value is
<int> plus the increment specified in the GEN_ID()
<step> parameter.
The syntax for SET GENERATOR
is:
SET GENERATOR NAME TO int;
The following statement sets a generator value to 1,000:
SET GENERATOR CUST_NO_GEN TO 1000;
Important:
Don’t reset a generator unless you are certain that duplicate numbers will not occur. For example, a generators are often used to assign a number to a column that has
Don’t reset a generator unless you are certain that duplicate numbers will not occur. For example, a generators are often used to assign a number to a column that has
PRIMARY KEY
or UNIQUE
integrity constraints. If you reset such a generator so that it generates duplicates of existing column values, all subsequent insertions and updates fail with a “Duplicate key” error message.