Subject | Re: [firebird-support] Re: Generators for auto-increment - with override |
---|---|
Author | Daniel L. Miller |
Post date | 2005-01-08T21:04:45Z |
Adam wrote:
enough that I don't even trust myself. The max() check was the simplest
way I came up with to guarantee the validity of the id.
behaviour in a SP will make a difference in my toggling it on/off.
--
Daniel
>>Thanks very much for the responses - but they don't quite answer myThank you - I don't usually pick up on hints (as my wife will attest!).
>>questions. To re-state:
>>
>> Question #1: Where should I implement "generator protection" -
>>before or after inserts/updates?
>>
>>
>I think they were answered quite well already, but to spell it out in
>black and white, if you choose to implement it, put it in both insert
>and update triggers, I recommend before insert and before update
>because it at least is incremented sooner.
>
>
>> Question #2: Should I keep this "protection" in a productionAssuming I trust any manually specified id - sometimes I'm paranoid
>>environment?
>>
>>
>Most people have advised you against it. Certainly the way you
>originally wrote it was really inefficient, but you could probably get
>away with leaving it in place providing you get rid of the select
>max(id) bit and just compare new.id to the generator value.
>
>
enough that I don't even trust myself. The max() check was the simplest
way I came up with to guarantee the validity of the id.
>You should not need this protection in the production environmentPerhaps, probably, hopefully, should not. Being able to specify this
>though. I can understand its use in a development/testing environment
>when manually manipulating tables to confirm behaviour, but any
>program should call for the generator value first. Perhaps you can
>create the trigger and store the definition as a .sql file. Then if
>you need to work on the production database, run the .sql against it.
>
>
behaviour in a SP will make a difference in my toggling it on/off.
--
Daniel