Subject | Re: [IBO] About post, commit, delete |
---|---|
Author | Gediminas |
Post date | 2003-09-22T09:19:50Z |
Ok, what I have (it seems the same what Helen wrote):
1. trigger BEFORE INSERT, active:
BEGIN
if ( NEW."ClassDance_ID" is null ) then NEW."ClassDance_ID" = gen_id(
"Gen_ClassDance_ID_BI" , 1 );
END
2. generatorlinks:
pQuery->GeneratorLinks->Add(
"CLASS_DANCES.\"ClassDance_ID\"=\"Gen_ClassDance_ID_BI\"" );
3. left stuff (it's not needed, but provide in case):
pQuery->SQL->Add( "select ks.* , s.\"Name\" from CLASS_DANCES ks inner join
DANCES s on ks.\"Dance_ID\"=s.\"Dance_ID\";" );
pQuery->KeyLinks->Add( "CLASS_DANCES.\"ClassDance_ID\"" );
pQuery->KeyRelation = "CLASS_DANCES";
pQuery->RequestLive = true;
pQuery->MasterLinks->Add( "CLASS_DANCES.\"Class_ID\"=CLASSES.\"Class_ID\"" );
pQuery->MasterSource = pDataSource;
At 2003.09.22 10:01, you wrote:
The Truth Is Out There
1. trigger BEFORE INSERT, active:
BEGIN
if ( NEW."ClassDance_ID" is null ) then NEW."ClassDance_ID" = gen_id(
"Gen_ClassDance_ID_BI" , 1 );
END
2. generatorlinks:
pQuery->GeneratorLinks->Add(
"CLASS_DANCES.\"ClassDance_ID\"=\"Gen_ClassDance_ID_BI\"" );
3. left stuff (it's not needed, but provide in case):
pQuery->SQL->Add( "select ks.* , s.\"Name\" from CLASS_DANCES ks inner join
DANCES s on ks.\"Dance_ID\"=s.\"Dance_ID\";" );
pQuery->KeyLinks->Add( "CLASS_DANCES.\"ClassDance_ID\"" );
pQuery->KeyRelation = "CLASS_DANCES";
pQuery->RequestLive = true;
pQuery->MasterLinks->Add( "CLASS_DANCES.\"Class_ID\"=CLASSES.\"Class_ID\"" );
pQuery->MasterSource = pDataSource;
At 2003.09.22 10:01, you wrote:
>You *still* have the keylinks problem with inserts though, because you are--/ Gediminas /--
>letting the trigger create the primary key. You need to do this:
>
>1. Make your trigger:
>
>create trigger atrigger for "CLASS_DANCES"
>active before insert
>as
>begin
> if (new."ClassDance_ID" is not null) then
> new."ClassDance_ID" = gen_id(YourGenerator, 1);
>end
>
>then
>2. Set the GeneratorLinks property:
>
>"ClassDance_ID"=YourGenerator
>
>This enables the dataset to fetch the new PK value during the BeforeInsert
>phase and add it to the key buffer. Then, your inserted row is all taken
>care of after the commit, with BufferSynchro.
The Truth Is Out There