Page 1 of 1

Master-Detail with Zeos

Posted: 10.08.2011, 03:07
by elidorio2
Good night

How to connect with Master-Detail Zeos?

Thanks,
Edson

Posted: 15.02.2012, 13:13
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;

Posted: 28.04.2012, 20:25
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

Posted: 03.05.2012, 21:02
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

Posted: 22.06.2012, 02:03
by elidorio2
mmvisual,

already implemented the above code, and is not yet possible to save master and detail in a single transaction.

Posted: 22.06.2012, 07:23
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

Posted: 22.06.2012, 11:31
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

Posted: 22.06.2012, 13:06
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

Posted: 22.06.2012, 14:05
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.

Posted: 22.06.2012, 15:56
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

Posted: 16.07.2012, 15:45
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