Page 1 of 1

ZQuery update

Posted: 05.11.2008, 02:52
by lams
Hi,

I am using Zeos 6.6.4 with Firebird 2.1

I have a little bit confuse about how to use ZQuery with ZUpdateSQL. I used to put a ZQuery and ZUpdateSQL into the Form, and set ZQuery.UpdateObject to the ZUpdateSQL. Then set the Insert/Update/Modify/Delete/Refresh SQL under ZUpdateSQL component for updating data.

But I just find out ZQuery actually is not a read-only dataset. If my code like this without a ZUpdateQL:

Code: Select all

While not ZQuery.Eof do
begin
  ZQuery.Edit; // Note: no ZUpdateSQL Assign to UpdateObject property
  ZQuery.FieldByName('Title').AsString = 'Test';
  ZQuery.Post;
  ZQuery.Next;
end;
It actually work! So my question is:

Do ZQuery equal to TQuery? Or something special I miss?

Cheers,

Posted: 05.11.2008, 07:59
by Jay
If you use a TZQuery component and you select from only 1 table, then the dataset is Read/write since the component knows how to do the updates (Insert, update, delete). Example

SELECT * FROM Employees

However, if you select from 2 or more tables, then the component DOES NOT know which table or fields to update. In these cases, you must use the TZUpdateSql component in which YOU specify what table and fields to update and how.

Regards,
Jay

Posted: 05.11.2008, 09:07
by mdaems
Do ZQuery equal to TQuery? Or something special I miss?
They have (about) the same functionality, indeed. They can't be simply swapped, however. A ZQuery always depends on a ZConnection, a TQuery doesn't. When it's about documentation : normally functionality described in Delphi Help about a TQuery should be equal (or very similar) for a ZQuery.

The difference : you don't need the BDE for the zeoslib components. You only need the client dll's for the database of your choice.

Mark

Posted: 06.11.2008, 03:29
by lams
Thank you for both explanations.

I haven't use TQuery for years and already regard it as a read-only dataset as TIBQuery in the IBX.