Subject RE: [firebird-support] Generator and Trigger confusion ?
Author Wilson, Fred
We *never* allow an application (user) to supply the PK value.
The PK is always completely separate from any meaningful data, as it should
be.
We use generators for PK values on all but a handful of "static" data tables
that we (Böwe Bell & Howell) populate via upgrade scripts.
Some of the tables have triggers that use the generator to get the PK on
insert, however most don't use triggers.
For most tables, we have stored procedures that do they inserts and they
call the generator to get the PK value.


Best regards,
Fred Wilson
SE, Böwe Bell & Howell
fred.wilson@... <mailto:fred.wilson@...>



-----Original Message-----
From: Milan Babuskov [mailto:albis@...]
Sent: Tuesday, November 11, 2003 10:42 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Generator and Trigger confusion ?


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 <http://fbexport.sourceforge.net>




Yahoo! Groups Sponsor

ADVERTISEMENT

<http://rd.yahoo.com/SIG=12cp4unj2/M=258297.4155332.5363524.4049140/D=egroup
web/S=1705115386:HM/EXP=1068658892/A=1683962/R=0/*http://www.techsmith.com/r
dr/ban/syah/default.asp> click here

<http://us.adserver.yahoo.com/l?M=258297.4155332.5363524.4049140/D=egroupmai
l/S=:HM/A=1683962/rand=637515410>

To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .




[Non-text portions of this message have been removed]