Subject | Re: [firebird-support] Auto Incrementing field |
---|---|
Author | Alex Taylor |
Post date | 2003-12-09T16:36:51Z |
Yes they are right above. The general implementation of an
auto-increment field in FireBird is to create a BeforeInsert trigger and
a generator for that field. In the BI trigger write the following:
IF NEW.YOUR_FIELD_NAME IS NULL THEN
BEGIN
NEW.YOUR_FIELD_NAME=GEN_ID(GEN_YOUR_FIELD_NAME,1);
END
This will ensure a unique value for that field and will insert a value
only if the value being inserted is null. This is usefull when you
insert via script and then there is no need to deactivate the trigger.
Regards:Alex
auto-increment field in FireBird is to create a BeforeInsert trigger and
a generator for that field. In the BI trigger write the following:
IF NEW.YOUR_FIELD_NAME IS NULL THEN
BEGIN
NEW.YOUR_FIELD_NAME=GEN_ID(GEN_YOUR_FIELD_NAME,1);
END
This will ensure a unique value for that field and will insert a value
only if the value being inserted is null. This is usefull when you
insert via script and then there is no need to deactivate the trigger.
Regards:Alex