[Delphi/TZUpdateSQL vs. TZQuery] Making changes?

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
littlebigman
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 15.05.2009, 14:33

[Delphi/TZUpdateSQL vs. TZQuery] Making changes?

Post by littlebigman »

Hello

I'm told that to it's possible to make changes to a dataset in Delphi using either TZQuery (which I thought could only SELECT data) or TZUpdateSQL.

I find using the same component (TZQuery) to read and write data more natural than relying on a second component, so could someone tell me in which case it's better to use which component, and why?

Thank you.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

TZQuery have benefit that automatically generate update/insert/delete queries, but only if select query is simple enough (eg. from one table). If SQL select is some kind of join, TZQuery won't know which table to update and query is read-only. You need finer control and that's why (but not only) TZUpdateSQL is for. With TZUpdateSQL you can select from joined table and update only first, only second, (or even third) one. Or you can insert into log_table instead delete or edit multiple tables at once, or select from stored proc and update table... Problem is that you must take care about all SQL, not just selects.
Which is better?? Depends about problem you want to solve and personal preferences. Pick your poison :wink:
Post Reply