Subject | Re: [IBO] problem |
---|---|
Author | Helen Borrie |
Post date | 2001-08-22T09:40:06Z |
At 11:01 AM 22-08-01 +0200, you wrote:
To do master-detail, you need a master record structure with a primary key, and 0 to n details records, each one carrying a foreign key which points to the primary key of the master structure. (The foreign key column does not need to have a FOREIGN constraint, although it is quite common to enforce the relationship this way).
The detail dataset
1 - selects the datasource of the master as its MasterSource
2 - in its MasterLinks property, matches its "foreign key" column to the KeyLinks property of the master dataset, e.g.
MYFOREIGNKEY=MASTERTABLE.PRIMARYKEY // don't leave any spaces
(substitute the real names of the columns and table)
Now, if you place the detail dataset in the data-aware grid, you will see only the detail rows whose MasterLinks column(s) match the KeyLinks column(s) of the currently selected master row.
There is another way to form the master-detail relationship that does not need to use MasterLinks. You still need to have the same kind of "matching" between a column in the master dataset and a column in the detail datataset but, this way, you pass the "master key column" in the master dataset across to the detail dataset as a parameter.
You still need to select the MasterSource, as before. However, this way, you define MasterParamLinks instead of MasterLinks. The SQL statement of the detail dataset will include a WHERE clause that contains a parameter, e.g.
...WHERE PARENTKEY = :PARENTKEY...
The MasterParamLinks looks like
PARENTKEY=MASTERTABLE.PRIMARYKEY
(substitute the real names of the columns and table)
Take a look at the Masterlinks sample project.
hth
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Hi,This doesn't sound right - are you saying that you store the master record and the detail records in one single table?
>
>I am using IBO Version 3.4.Cm
>
>in a table I have a 'master' record and 'detail-records'. In the master
>record I have the number of my client.
To do master-detail, you need a master record structure with a primary key, and 0 to n details records, each one carrying a foreign key which points to the primary key of the master structure. (The foreign key column does not need to have a FOREIGN constraint, although it is quite common to enforce the relationship this way).
>Now I need to show the records concerning a specifiek clientnumber in anYou will need to arrive at two datasets, a master and a detail. Define the KeyLinks of the master dataset as (usually) the primary key column(s) of the master table.
>IBO-grid. If I do so, I
>have only my 'master' record off course.
The detail dataset
1 - selects the datasource of the master as its MasterSource
2 - in its MasterLinks property, matches its "foreign key" column to the KeyLinks property of the master dataset, e.g.
MYFOREIGNKEY=MASTERTABLE.PRIMARYKEY // don't leave any spaces
(substitute the real names of the columns and table)
Now, if you place the detail dataset in the data-aware grid, you will see only the detail rows whose MasterLinks column(s) match the KeyLinks column(s) of the currently selected master row.
There is another way to form the master-detail relationship that does not need to use MasterLinks. You still need to have the same kind of "matching" between a column in the master dataset and a column in the detail datataset but, this way, you pass the "master key column" in the master dataset across to the detail dataset as a parameter.
You still need to select the MasterSource, as before. However, this way, you define MasterParamLinks instead of MasterLinks. The SQL statement of the detail dataset will include a WHERE clause that contains a parameter, e.g.
...WHERE PARENTKEY = :PARENTKEY...
The MasterParamLinks looks like
PARENTKEY=MASTERTABLE.PRIMARYKEY
(substitute the real names of the columns and table)
Take a look at the Masterlinks sample project.
hth
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________