Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: Problem with master- detail
Problem with master- detail
Posted: 2007/05/03 12:29
 
Am unable to get master-detail working
Master is defined as:
select BID, SupplierpkBID from order
order.BID is primary key

Detail is defined as:
select BID,orderpkBID,amount from orderrow where orderpkbid = :KeyBID

orderrow.BID is primary key, orderpkbid is foreignkey to order

The parameter KeyBID was correctly created and I set the mastersource to order and masterfield to BID. This did not work. logging showed that a <null> value was put into xBID parameter.
Then I tried to use indexfieldname as in the masterdetail demo but did didn''t work either.
Is the problem that I MUST use the same fieldname in master and detailtable to connect?

Arjan

Post edited by: ArjanNoordhoek, at: 2007/05/03 12:31
Re:Problem with master- detail
Posted: 2007/05/04 02:10
 
Is the problem that I MUST use the same fieldname in master and detailtable to connect?
Yes, exactly. ThinDAC assigns the field values of master dataset to corresponding detail dataset parameters, where parameter name is the same as field name.

And of each master record change, ThinDAC will require detail records. Setting IndexFieldNames / IndexName, MasterFields and including fiDetails into FetchOptions.Cache, ThinDAC will apply range to the detail records. And if there are no records, then will requery detail records. So, detail records will be cached.

And also, you can use SQL command without parameters for detail dataset. In this case, ThinDAC will not requery detail records. And will just apply range, as described above.

Regards,
Dmitry
Re:Problem with master- detail
Posted: 2007/05/04 03:10
 
Hi Dmitry,

Got the master-detail working after changing the parameter name to :BID.
However I found a second problem.
I have a form with two grids, one for the master and one for the detail.
If I focus the master grid and press the down key twice quickly I get an exception in getdata. When I do it slowly there is no problem.

function TADDatSRow.GetData(AColumn: Integer; AVersion:
..
ASSERT(Self <> nil);
oCols := Table.Columns; <-- this is where exception occurs
ASSERT(Length(oCols.FDataOffsets) <> 0);

if I deactive the detail dataset no exception occurs.

Arjan
Re:Problem with master- detail
Posted: 2007/05/04 03:22
 
What is your RTC SDK version ?
Re:Problem with master- detail
Posted: 2007/05/04 03:31
 
RTC SDK 2.61