Imagine the following Example:
2 Tables, bothe have the KeyField ID.
MasterDataSet
Code: Select all
SELECT id FROM mastertable
Code: Select all
SELECT id, detaildata, mastertable_id FROM detailtable WHERE mastertable_id=:id
Code: Select all
CREATE TABLE mastertable(id SERIAL PRIMARY KEY, data VARCHAR);
CREATE TABLE detailtable(id SERIAL PRIMARY KEY, mastertable_id INTEGER REFERENCES mastertable, detaildata VARCHAR);
So master Detail is working fine in this way."Working with Master/Detail Relationships" Pay attention to one thing: parameter name in detail dataset SQL must be equal to the field name in the master dataset that is used as foreign key for detail table.
If u call RefreshRecord on the DetailDataSet now, DevArt will add the Where Clause depending on the KeyFields. The KeyField in the Detail is "id" too. Additionally the Where Clause added will get a Parameter with the same Name as the Key Field, in this Case "Id" too.
The Result is, that a ParameterOverload happens. The Resulting SQL will be
Code: Select all
WHERE
mastertable_id=:id
AND
id=:id < this part is added for RefreshRecord of Detail.
Solution: wether u make a random-paramname, or u check out if the paramname already exists and make it another name.
WorkAround: In DetailDataSet:
Code: Select all
SELECT id AS myid, detaildata, mastertable_id FROM detailtable WHERE mastertable_id=:id
Code: Select all
DetailDataSet.KeyFields:='myid'
Code: Select all
WHERE mastertable_id=:id
AND
id=:myid < this part is added for RefreshRecord of Detail.