Subject Delphi + Firebird specific
Author Uwe Oeder
If this forum is not the right one to answer my question would somebody
then please redirect me to the correct messagebord.

I have 2 tables one is the master one the slave. When I insert a record
into the master record everything is file. It calls the appropirate trigger
and the records is assigned a unique identifier for its primary key through
a generator.

DtSrcMaster.DataSet.AppendRecord([0,TheName,TheDescription]) ;

So far so good. This is the trigger.

CREATE TRIGGER TrigGenWhitePage FOR Whitepage
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF ((NEW.WpIDSQ = 0) OR (NEW.WpIDSQ IS NULL)) THEN
NEW.WpIDSQ = GEN_ID(GenWhitepage,1) ;
END !!

Then I immediately query the current master record for its primary key so I
can link the child record to the master record.

MyVariant := DtSrcMaster.DataSet.FieldByName('MasterID').AsVariant ;

However the master always reports back the value which I send with the
append record procedure call , in this case 0. So the child records
insertion fails as the link to the master record is false. Yet the master
record is inserted into the table with the correct MasterID which is not 0.