Master-Detail with Zeos

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Master-Detail with Zeos

Post by elidorio2 »

Good night

How to connect with Master-Detail Zeos?

Thanks,
Edson
mparak
Senior Boarder
Senior Boarder
Posts: 81
Joined: 12.09.2005, 06:51
Location: Durban South Africa
Contact:

Post by mparak »

Form1.test_Master_Detail;
var Master,Detail:TzQuery ds_Master:TDatasource;
Begin
try
Master:=TzQuery.Create(application);
Master.connection:=Zconnection1;
Detail:=TzQuery.Create(application);
detail.connection:=Zconnection1;
ds_Master:=TDatasource.Create(application);
Master.sql.text:='select * from master_table';
Master.OPen;
ds_Master.dataset:=Master;
detail.datasource:=ds_Master;
detail.sql.text:='select * from detail_table where linkField=:linkField';
detail.open;
{
Master and detail are now opened and linked perfectly. Enjoy!
}
finally Master.free;Detail.free;ds_Master.free; end;
end;
Mohammed Parak
CAD RETAIL
Durban South Africa
http://www.cad.co.za
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

Hello mparak,

You can record the detail is a single transaction that is, to record the detail also the master record. How is the ClientDataSet?

Edson
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Post by mmvisual »

Here the right code:

Code: Select all

var Master,Detail:TzQuery ds_Master:TDatasource;
Begin
  // Create
  Master:=TzQuery.Create(application);
  Detail:=TzQuery.Create(application);
  ds_Master:=TDatasource.Create(application);
  Master.connection:=Zconnection1;
  detail.connection:=Zconnection1;
  ds_Master.dataset:=Master;

  // Master Table
  Master.sql.text:='select * from master_table';
  Master.OPen;

  // Detail Table
  detail.LinkedFields := '<master_table_ID>'; // Fieldname from detail table
  detail.MasterFields := '<ID>'; // Fieldname from master table
  detail.MasterSource := ds_Master;
  detail.sql.text:='select * from detail_table';
  detail.open;
Regards Markus
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

mmvisual,

already implemented the above code, and is not yet possible to save master and detail in a single transaction.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

elidorio2,

that is true an not supported from any component. If you use a Statement whitch joins the tables you need then you can use the TZUpdateSQL-Component and you can write all fields to all tables if your defined Statements are valid, Edson. But with a Master/Detail-Components it is not supported...

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

OK, Michael,
Zeos would be interesting to implement the Master / Detail, is equal to the ClientDataSet.
It is a very interesting feature that would look good on Zeos.

Edson
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello,

I always use the form showed by mparak. The name of the detail parameter must be equals of the name of field in the master query.

:)

Bye bye,

Josimar
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

josimarz,

i think that is not the purpose of elidorio2's second post. IF i understand him right then he want to Update the Master and Detail dataset in the same transacton if he uses tiReadCommited for example. Which means (i hope i do undestand him here right) if he says MasterQuery.Edit then the should the DetailQuery equal be updateable. And if he want to Post the updated row then both datasets should execute the update command in the same transaction session..

elidorio2, is that right what i think?

Michael

Btw. in mparak, post is the LinkedFields property missing so i don't think that anybody has success with his incomplete post. The post of mmvisual, is complete and should work.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Post by elidorio2 »

Michael,
That's right, I want to run a single commit, which is saved in the database, the master and detail in a single transaction.
example:
1 - Insert the data from the master
2 - I insert data items, for example 5 item
3 - It is to save in a single commit, save the master and detail of the five items.

Edson
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

elidorio2,

Can you prepare me a test-case? You can use the bug-template or. Make me a test ready which i can add to the test suites. Then we have a reminder and can solve your requests...

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Locked