Master-detail - INSERT

Master-detail - INSERT

Postby sean » Sun 20 Mar 2005 12:06

Hi,

I have a master & 5 details tables. The Detail tables have MasterSource, MasterFields, DetailFields set. When I browse the master, the cursors on the details follow just fine.

When I do a Table.Insert though, an entry is only inserted into the master, any OnNewRecord is is only called for the Master.

Why? Should the INSERT of the detail tables not be automatic?

Thanks in advance,

Sean Boran
sean
 

Postby sean » Sun 20 Mar 2005 12:20

I also wished to add, that I do

ShowMessage('Insert');
dmJOB.taJOBCARD.Insert;
ShowMessage('post');
dmJOB.taJOBCARD.Post;

but that I don't see the INSERT in the DBmonitor, nor is a row inserted into the master table (taJOBCARD)

In dmJOB.taJOBCARDNewRecord I have
with DataSet do begin
FieldByName('jcard_no').value:=current_job;
ShowMessage('taJOBCARDNewRecord ' +FieldByName('jcard_no').AsString);
end;

And I do see the ShowMessage with the currect value for the Index.

What am I doing wrong?

Sean
sean
 

Postby Ikar » Mon 21 Mar 2005 09:25

> Why? Should the INSERT of the detail tables not be automatic?

Yes, according to Master-Detail ideology insertion a record in Master is a little related with insertion a record in Detail. For Detail you also need to execute Insert..Post manually.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby Sean » Mon 21 Mar 2005 09:39

> Yes, according to Master-Detail ideology insertion a record in Master is a little related with insertion a record in Detail. For Detail you also need to execute Insert..Post manually.

Hmm. And to set the value of the primary index after insert, I should be able to do it in the OnNewRecord event? Because in the example I list, the new row is NOT posted to the master (leaving aside the detail tables).

with DataSet do begin
FieldByName('jcard_no').value:=current_job;
ShowMessage('taJOBCARDNewRecord ' +FieldByName('jcard_no').AsString);
end;

I get the showmessage, but no row appears in the table.
Sean
 


Return to MySQL Data Access Components