Page 1 of 1

[Delphi/TZUpdateSQL vs. TZQuery] Making changes?

Posted: 01.06.2009, 21:57
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.

Posted: 01.06.2009, 22:51
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: