Subject | Re: [firebird-support] Re: Getting ID from generator |
---|---|
Author | Milan Babuskov |
Post date | 2005-12-16T15:26:18Z |
Adam wrote:
and move generator beyond it.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org
>>Although this is a common pratice, I've run into issues many times. IfNo, it won't. I don't touch the inserted value, I use the one supplied
>>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.
>
>
> Not always a good practice though.
>
> A common use for this technique is if you are maintaining a master
> detail relationship in a clientdatset or equivalent. You can fire off
> the appropriate queries as required to pull in the true PK values to
> be used.
>
> Using your trigger, the relationship would be broken upon insert.
and move generator beyond it.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org