|
This approach has to consider some potential risks:
When using this Generator technique, at the moment you insert a new record to the table using the front-end application (programmed in Delphi, for example), you don't know which value the 'CUST_HASH' field will take. And if that field is your PRIMARY KEY, then you're in serious trouble, because you need to set your transaction to 'READ COMMITED' and refresh the dataset in order to see the real value that this field has after the record insert, since the trigger assigns it a value.
And also I would drop the IF (NEW.cust_hass is NULL) sentence in this trigger, since it opens the door for values for this field to be entered by the user, hence it could lead to duplicate values if later is uses the generator. Remember that the generator just increments by one when you call the GEN_ID function; if the generated value already exists in the table, then the generator will be unable to detect it.
The use of generators should be done with great care.
|