Master detail

RamosIt

Member²
Hi.
I have a big deal using master-detail.
dataset A is master for dataset B.
I insert a master with success. then i insert a detail with success. As i try to insert another detail i get an error of integrity constraint. Here the pseudo code...
-------------------------------------------
A,B are TOracleDtaset
MasterPk is integer
GetNewMasterPK,GetNewDetailPk are functions returning new pk

MasterPk := GetNewMasterPK;
A.insert; --> OK
A.fieldbyname('PK').Value := MasterPk; --> OK
DetailPk := GetNewDetailPk ;
B.insert; --> OK;
B.fieldbyname('PK').Value := GetNewDetailPK; --> OK
b.fieldbyname('FK').Value := MasterPK; --> OK
DetailPk := GetNewDetailPk;
B.insert; --> Foreign key error!!

Can you help me??

 
Looking at Oracle Monitor i see that when i attempt do B.insert second time B tries to insert first detail record... althought i have not yet posted master.
 
Back
Top