Subject Re: [firebird-support] Generator and Trigger confusion ?
Author Milan Babuskov
Uwe Oeder wrote:
> I am getting a bit confused between all the different methods to use ?
> Which version does the general / average suggest ?!. And should I then
> assume that the example of a Generator / Trigger in the Langref.PDF file
> top of page 59 is outdated ???

AFAIK, The Right Thing (TM) is to use trigger to fill PK value from
generator. You can allow user to supply PK value (if it is needed for
something, so he doesn't have to deactivate trigger for that operation)

Something like this:

CREATE TRIGGER table1_bi FOR table1
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.pk IS NULL) THEN
NEW.pk = GEN_ID(GEN_table1_ID,1);
END

Since generators have big range, you can also use the single generator
for all tables. It all dependins on your personal preference ;)

--
Milan Babuskov
http://fbexport.sourceforge.net