ParamByName in Master/Detail

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
vejrous
Junior Boarder
Junior Boarder
Posts: 27
Joined: 19.02.2017, 21:33

ParamByName in Master/Detail

Post by vejrous »

Hi, I have 2 TQuery components conected with TQuery2.Datasource property.

TQuery1, MasterSQL:
SELECT id, field1, field2
FROM master


TQuery2, DetailSQL:
SELECT field1, master_id
FROM detail
WHERE master_id = :id


Question: is TQuery2.ParamByName('id') automaticly set, when using this type of connection?

Purpouse:
I connect TQuery2 with Datasource property when records should dynamicly change or with ParamByName when other type required (usually some modal form).

So when you call:

Code: Select all

procedure TDatamodule.qryQuery2BeforePost(DataSet: TDataSet);
begin
  // this part should not be needed
  if Assigned(qryQuery2.DataSource) then
    fldQuery2ID.AsString := qryQuery2.DataSource.DataSet.FieldByName('id').AsString
  // this should be enought for both versions  
  else
    fldQuery2ID.AsString := qryQuery2.ParamByName('id').AsString;
end;
Is this how Zeos works or am I something missing?
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: ParamByName in Master/Detail

Post by marsupilami »

Hello Vejrous,

usually I implement that kind of thing on my own in the after scroll event of the master dataset and in the before post of the detail dataset. But there is a (possibly outdated) documentation on how to use master - detail in Zeos. Take a look at the Documentation Collection, Topic "Master/Detail with ZEOS Library", Page 21. But I have to admit that although I compiled the documentation, I still didn't get around to testing it. Please let me know if this helps you or not.

With best regards,

Jan
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: ParamByName in Master/Detail

Post by Fr0sT »

In short, M-D relationship in Zeos is achieved by this:

Code: Select all

  object qDetail: TZQuery
    DataSource = dsMaster
    MasterFields = 'ID'
    LinkedFields = 'RecordID'
  end
Where 'ID' is a key field in Master and 'RecordID' is FK field of Detail
Post Reply