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
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 19.02.2017, 21:33

ParamByName in Master/Detail

Postby vejrous » 27.11.2017, 11:16

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?

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);
  // 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 
    fldQuery2ID.AsString := qryQuery2.ParamByName('id').AsString;

Is this how Zeos works or am I something missing?

Gold Boarder
Gold Boarder
Posts: 674
Joined: 17.01.2011, 14:17

Re: ParamByName in Master/Detail

Postby marsupilami » 28.11.2017, 09:10

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,


Zeos Dev Team
Zeos Dev Team
Posts: 120
Joined: 08.05.2014, 12:08

Re: ParamByName in Master/Detail

Postby Fr0sT » 28.11.2017, 14:44

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

Code: Select all

  object qDetail: TZQuery
    DataSource = dsMaster
    MasterFields = 'ID'
    LinkedFields = 'RecordID'

Where 'ID' is a key field in Master and 'RecordID' is FK field of Detail

Return to “ZeosLib 7.2 Forum”

Who is online

Users browsing this forum: No registered users and 1 guest