Subject | RE: [IBO] GeneratorLinks in 5,000,000 words or less |
---|---|
Author | Helen Borrie |
Post date | 2001-02-07T22:48:33Z |
At 04:11 PM 07-02-01 -0500, you wrote:
The following code is !!!! dangerous !!!!. Generators operate right
outside the transaction context. In a multi-user environment, you are
certain to get PK violations. Don't do it!!!
try to insert rows where the PK comes from another source that **that**
generator.
To add a further note on GeneratorLinks, you should always use it when
inserting into a bi-directional dataset, rather than waiting until after
the insert has committed, to ensure that the KeyLinks will work
properly. Reserve the use of the trigger for external clients or scripts.
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Hello PaulEND THE TRIGGER HERE !!!
>
>GeneratorLinks is to allow IBO to go ahead and get the
>ID of the record before the actual insert. This allows
>it to pass it along to Detail tables that could be connected
>and other things. You don't have to use it for positioning,
>I think you are talking about keylinks.
>
>I use the following trigger on my tables:
>
> create trigger TRGBEFINS_Customer for Customer
> active before insert position 0
> as
> DECLARE VARIABLE Temp_ID integer;
> begin
> if ((new.Cus_ID is NULL) or (new.cus_ID = 0)) then
> begin
> new.Cus_ID = gen_id (Gen_Customer_ID, 1);
The following code is !!!! dangerous !!!!. Generators operate right
outside the transaction context. In a multi-user environment, you are
certain to get PK violations. Don't do it!!!
> end else beginIf you are using a generator to populate a primary key, you should NEVER
> Temp_ID = gen_id(Gen_Customer_ID,0);
> if (new.CUS_ID > Temp_ID) then
> begin
> Temp_ID = gen_id(Gen_Customer_ID, new.Cus_ID-Temp_ID);
> end
> end
> end
>
>It will update your generator if necessary and also, make
>sure that the generator doesn't get behind if you inserted
>records that had IDs not derived from the generator.
try to insert rows where the PK comes from another source that **that**
generator.
To add a further note on GeneratorLinks, you should always use it when
inserting into a bi-directional dataset, rather than waiting until after
the insert has committed, to ensure that the KeyLinks will work
properly. Reserve the use of the trigger for external clients or scripts.
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________