Subject | Re: [firebird-support] Re: Getting ID from generator |
---|---|
Author | Milan Babuskov |
Post date | 2005-12-15T16:52:29Z |
Adam wrote:
you do provide the value, it might clash with autogenerated one in the
future. So I mostly rewrite the triggers like this:
create trigger...
begin
if (new.microarrayid is null) then
new.microarrayid = gen_id(microarray_id_gen, 1);
else
check if new.microarrayid is bigger than
the generator value
and move the generator up to it
Well, not so simple, but effective.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org
> Firstly, change your trigger to this.Although this is a common pratice, I've run into issues many times. If
>
> set term !! ;
> create trigger create_microarray_id for microarray_main
> before insert position 0
> as begin
> if (new.microarrayid is null) then
> begin
> new.microarrayid = gen_id(microarray_id_gen, 1);
> end
> end !!
> set term ; !!
you do provide the value, it might clash with autogenerated one in the
future. So I mostly rewrite the triggers like this:
create trigger...
begin
if (new.microarrayid is null) then
new.microarrayid = gen_id(microarray_id_gen, 1);
else
check if new.microarrayid is bigger than
the generator value
and move the generator up to it
Well, not so simple, but effective.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org