Master Detail - Insert in Master

Robertio

Member²
I have a master detail setup between 2 TOracleDatasets which works fine.

On Insert of the Master table the value of the keyfield is set in the master dataset, unfortunately it does not run the query on the detail dataset for this new value, so the detail dataset does not point at the required record
frown.gif


If the master dataset is being edited, rather than inserted it works fine, and runs the detail query when the keyfield is changed.
smile.gif


Is there any way of getting it to work the same way when inserting?

Thanks
 
The standard master/detail concept of Direct Oracle Access assumes that there is a foreign key relation between the 2 tables. In that case, there will never be any detail records for a newly created master record.

In your situation you probably need to explicitly refresh the detail dataset after e new master record is posted.

------------------
Marco Kalter
Allround Automations
 
Cheers, that's what it seemed like, had to improvise and run a separate query to bring back the detail values in order to view them without having to post the master record.
 
Hi, I have the same problem. In my case the detail dataset is a read-only dataset which does a kind of lookup for a particular field in the master. Each time I change that field, the detail should update. But after an insert on the master, the detail dataset keeps empty until an ApplyUpdates is executed.

You suggest to refresh the detail dataset manually. In which way I should refresh the detail dataset? When I use active=false; and active=true; the detail dataset keeps empty.

I have solved this problem by not setting the master property of the detail dataset, and add an event for both the AfterScroll of the master dataset and the OnChange of the master TField. In the handler I execute:

tblDetail->Active=false;
tblDetail->SetVariable("X_ID",tblMaster->FieldByName("X_ID")->AsVariant);
tblDetail->Active=true;

This works as expected, but why is this not possible using an automatic master/detail relation after an insert on the master?

(btw I am using BCB5 and DOA 4.0.6.2)
 
For my previous suggestion to manually refresh the detail dataset did indeed imply that you should not use the Master/Detail properties of the TOracleDataSet.
 
Back
Top