m x n relation, how to do efficiently designtime.

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
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

m x n relation, how to do efficiently designtime.

Post by marcov »

I've a m x n relation decoupled using a 3rd table.

So Person and Contact have a m x n relation, decoupled by having a table "PCconnect" that has a reference to the IDs (PK) of each of the other two.

I looked in the examples of both 6 and 7, and could not find an example or something that has such relation.

I've only done serverside access, so while I'm not very familiar with designtime components, SQL is no problem.

I tried working from a dbgrid that joins these three tables together for a certain person.ID, with wired tdbedit etc controls, but don't know how to handle update/insert. Should I work from a tzupdate component and not tzquery?

Compiler D2009 (*)
Zeos 7, but this is more about general approach, I do not expect a ready made code.
db postgres 8.x

(*) yes, eat own dogfood etc, but this is for work
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

Post by marcov »

Ok, found tzquery.updateobject, and coupled a tzupdatesql to it.

I tried to mimic the masterdetail demo (from older zeoses), and it seems to work, though I don't fully understand what I have done.

I assume the update function reloads the grid, and the fields of the tzquery are then available in the SQL of the tzupdate component.

Like in masterdetail demo, I used the "newrecord" event of the tzquery to transfer parameters from tzquery to tzupdate (though I still see NULLs in sqlmonitor, so it is not 100% yet, even though it works)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

marcov,
This looks like a strange procedure : transferring parameters from tzquery to tzupdatesql.
As I understand (but I don't have lots of experience with TZUpdateSQL) the queries you define in TZUpdateSQL are launched automatically when you (auto)Post a modified TZQuery record. At that time te special placeholders in the queries are replaced by the corresponding record values.
Some more documentation is available in http://zeos.firmos.at/kb.php?mode=article&k=12

Succes ermee.

Mark
Image
Locked