Subject | Re: [IBO] More info |
---|---|
Author | Helen Borrie |
Post date | 2003-06-10T14:10:01Z |
At 01:41 PM 10/06/2003 +0000, you wrote:
primary key of the master table, masterlinks will not work with
TIBOQuery. It works exactly like TQuery in this respect (deliberately!),
not like TIB_Query. TQuery's masterlinking is only automatic if the two
columns have the same name.
TIBOQuery has no Mastersource property - you have to use Datasource, I
guess you know that already.
So...
you are half-way there by parameterising the detail set. The other half is
to add the masterlinking yourself in the master's AfterScroll event; and to
apply the foreign key value yourself when inserting a detail row.
In the master's AfterScroll:
DetailQuery.ParamByName('RefID').AsInteger :=
MasterQuery.FieldByName('ID').AsInteger;
In the detail's AfterInsert:
Dataset.FieldByName('RefID').AsInteger :=
Datasource.Dataset.FieldByName('ID').AsInteger;
Helen
>Helen,Ok, then if the foreign key of the detail table has a different name to the
>
>the masterkey is generated and the generatorlink is filled. It works
>all right. After inserting a master I get the generated ID at once.
>
>My masterquery is a "multi-table-query"
>SELECT TABLEA.*, TABLEB.NAME
>FROM TABLEA INNER JOIN TABLEB ON TABLEA.NAMEID = TABLEB.ID
>ORDER BY TABLEA.NAMEID
>
>Keyrelation := TABLEA
>
>My detailquery is:
>SELECT *
>FROM TABLEDETAIL
>WHERE REFID = :ID ORDER BY ID
primary key of the master table, masterlinks will not work with
TIBOQuery. It works exactly like TQuery in this respect (deliberately!),
not like TIB_Query. TQuery's masterlinking is only automatic if the two
columns have the same name.
TIBOQuery has no Mastersource property - you have to use Datasource, I
guess you know that already.
So...
you are half-way there by parameterising the detail set. The other half is
to add the masterlinking yourself in the master's AfterScroll event; and to
apply the foreign key value yourself when inserting a detail row.
In the master's AfterScroll:
DetailQuery.ParamByName('RefID').AsInteger :=
MasterQuery.FieldByName('ID').AsInteger;
In the detail's AfterInsert:
Dataset.FieldByName('RefID').AsInteger :=
Datasource.Dataset.FieldByName('ID').AsInteger;
Helen