Master-Detail with Zeos
Moderators: gto, EgonHugeist, olehs
Master-Detail with Zeos
Good night
How to connect with Master-Detail Zeos?
Thanks,
Edson
How to connect with Master-Detail Zeos?
Thanks,
Edson
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;
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;
Here the right code:
Regards Markus
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;
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
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
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/
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/
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
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.
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/
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/
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
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
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
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
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/
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/