Subject setting a generator inside a SP
Author Sergio H. Gonzalez
Hello! In the FB guide reads:


"Setting a generator directly to a certain value (“Update”)

PSQL

GEN_ID(<GeneratorName>,<NewValue> - GEN_ID(<GeneratorName>, 0 ) );


Warning

This is more of a dirty little trick to do what you normally cannot
and should not do in SPs and triggers: /setting/ generators. They
are for /getting/, not /setting/ values."

I have a trigger, that fills a field with a new value if the field is
empty and if it is not empty, just set the new value to the generator
(the field *is not* a PK, so there's no problem is someone alter the
value a duplicate some numbers... This is the part of the trigger:


if ((new.numero <= 0) or (new.numero is null)) then
new.numero = gen_id(gen_nro_ret_iibb, 1);
else
void = gen_id( gen_nro_ret_iibb, 1+ new.numero -
gen_id(gen_nro_ret_iibb,0) );


So... if the advice of the guide is not to do it... what is the "proper"
way to do it??? What are the actual risks of doing that??

thanks!!!!!!!

-s