Subject Re: [IBO] cascade relations
Author Paul Vinkenoog
Hi Stan,

>> * Make sure an ID is generated for newly inserted Classes and
>> Class_Dances records. Use GeneratorLinks for both queries (I've
>> explained how in an earlier post).
>> Also make sure you have "before insert" triggers for both tables
>> (and probably Dances too) that look like this:
>>
>> begin
>> if ( New.Blah_ID is null )
>> then New.Blah_ID = gen_id( Blah_Generator, 1 );
>> end
>>
>> ...so the ID that IBO had generated, and inserted, will not be
>> overwritten!

> If you use GeneratorLinks for your query, why do you need the before
> insert trigger? How can the id be overwritten when it is only being
> assigned by the GeneratorLinks in your query?

It can't :-)

Maybe this wasn't too clear. I wrote it because I already knew that
Gediminas uses before insert triggers in which the IDs are generated.
I probably should have written something like:

"If you assign the ID from within IBO using GeneratorLinks, and you
also have a before insert trigger assigning that same ID field from
the generator, then make sure the trigger only assigns the ID if
it's NULL. Otherwise the ID that IBO assigned will be overwritten
and the record as IBO sees it will have an invalid ID."


Greetings,
Paul Vinkenoog