Subject | Re: [firebird-support] Problem calling set generator... |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2006-11-07T14:16:53Z |
Helen Borrie wrote:
generator is increased by the max value rather than set to the max value.
A more general solution would be
select gen_id(GEN_PREFS,(coalesce((select max(PREF_SN) from
WHATEVER),0) - gen_id(GEN_PREFS, 0))) from rdb$database
which should set it to the max value regardless of the starting point of
GEN_PREFS (though if other users change GEN_PREFS or add to WHATEVER
while you do this, you risk 'duplicate or missing' values).
Set
> select gen_id(GEN_PREFS,(coalesce((select max(PREF_SN) fromThat should work OK if GEN_PREFS is 0 at the start. If not the GEN_PREFS
> WHATEVER),0))) from rdb$database
generator is increased by the max value rather than set to the max value.
A more general solution would be
select gen_id(GEN_PREFS,(coalesce((select max(PREF_SN) from
WHATEVER),0) - gen_id(GEN_PREFS, 0))) from rdb$database
which should set it to the max value regardless of the starting point of
GEN_PREFS (though if other users change GEN_PREFS or add to WHATEVER
while you do this, you risk 'duplicate or missing' values).
Set