Subject Re: [IBO] Master detail. don't work?
Author Jason Wharton
Is this still an issue?

Thanks,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: <purrinhos@...>
To: <IBObjects@egroups.com>
Sent: Tuesday, January 09, 2001 5:30 AM
Subject: Re: [IBO] Master detail. don't work?


> Actually it does if you include an = and the corresponding field in the
> master dataset.

No, no. It's better with an example:
Master table->
CREATE TABLE MASTERTABLE (
ID1 INTEGER NOT NULL,
ID2 INTEGER NOT NULL,
ADATE DATE,
ATEXT VARCHAR(20),);
ALTER TABLE MASTERTABLE ADD CONSTRAINT
PKMASTER PRIMARY KEY (ID1,ID2);
Detail table->

CREATE TABLE DETAILTABLE (
ID INTEGER NOT NULL,
MASTER_ID1 INTEGER NOT NULL,
MASTER_ID2 INTEGER NOT NULL,
SOMEDATA VARCHAR(20));

ALTER TABLE DETAILTABLE ADD CONSTRAINT
PKDETAIL PRIMARY KEY (ID);

ALTER TABLE MOVIMIENTO ADD CONSTRAINT
FK_DETAIL_MASTER FOREIGN KEY (MASTER_ID1,
MASTER_ID2) REFERENCES MASTERTABLE(ID1, ID2)
ON DELETE CASCADE ON UPDATE CASCADE;

Well, the Delphi part:
TMaster <- MASTERTABLE
DMaster <- Datasource of TMaster
TDetail <- DETAILTABLE

TDetail.MasterSource:= DMaster;
TDetail.MasterFields:='master_id1=id1;master_id2=id2';
or

TDetail.MasterFields:='detailtable.master_id1=mastertable.id1;d
etailtable.master_id2=mastertable.id2';

Now, when you inserts a record in the detail table the
"GetValuesFromMaster" method first tries to find the fields "id1"
and "id2" in the master table (until now, this it's all right), then
attempts to find the fields "id1" and "id2" in the detail table (this
it's the wrong part) to assign the values from "mastertable.id1"
asn"mastertable.id2". Of course this works in two pass (in a
loop) the first one for "id1" the last for "id2".

TIBOTable constructs the master-detail relation (the select
statement linking the detail with the master) fine, but doesn't
initialise well the detail fields.

Otro saludo
Francisco

>
> Keep in mind it didn't work with TTable either....
>
> HTH,
> Jason Wharton
> CPS - Mesa AZ
> http://www.ibobjects.com
>
>
> ----- Original Message -----
> From: <purrinhos@...>
> To: <IBObjects@egroups.com>
> Sent: Monday, January 08, 2001 10:35 AM
> Subject: [IBO] Master detail. don't work?
>
>
> > Hi,
> >
> > Master detail relations (with TIBOTables) doesn't work when the
> > fieldnames of the masterfields and the detail fields are different.
> > In the "GetValuesFromMaster" method is utilized the same
> > "FieldName"
> > to "FindField" both in "tmpDataSet" and
> > "Self" with the net result of
> > assign the incorrect value to the detail field of the new record.
> >
> > I hope this helps.
> >
> > Un saludo
> > Francisco
> >
> >
> >
> >
>
>
>