TZReadOnlyQuery<>TZQuery

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Terence
Zeos Dev Team
Zeos Dev Team
Posts: 141
Joined: 22.09.2005, 14:11
Location: Stuttgart
Contact:

TZReadOnlyQuery<>TZQuery

Post by Terence »

I am little bit confused about there is a TZReadOnlyQuery and a "TZQuery.Readonly" option.
Do we need both, what is the difference, advantage- disadantage?
fabian
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Hello Terence :)
The main difference between TZReadOnlyQuery and TQuery is that ReadOnly inherits TZAbstractRODataSet (Abstract Read Only Dataset) and normal Query inherits TZAbstractDataSet (Abstract Dataset) which inherits from TZAbstractRODataSet .

In other words, the ReadOnly doesn't have the write/edit subsystem/properties (the TZAbstractDataset Object) then the communication between application and database skips one level.

Never did any test, but, IMHO, for searches and other ReadOnly operations, TZReadOnlyQuery is the best. Waiting for more technical reviews :)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Terence
Zeos Dev Team
Zeos Dev Team
Posts: 141
Joined: 22.09.2005, 14:11
Location: Stuttgart
Contact:

Post by Terence »

Question is if ReadOnly Property in TZQuery is still usefull then`?
fabian
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Well Fabian, it actually is usefull when working with components. That way you can decide at runtime if the user is allowed to update the data or not. If not (because of some rule you programmed) just set the property to false and it's not possible for the user to change the data.

Mark
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

mdaems wrote:Well Fabian, it actually is usefull when working with components. That way you can decide at runtime if the user is allowed to update the data or not. If not (because of some rule you programmed) just set the property to false and it's not possible for the user to change the data.

Mark
Just a complement: If you try to alter data on a ReadOnlyQuery or Query with ReadOnly set to true, RaiseReadOnlyError will be called. In my version, this procedure is:

Code: Select all

{**
  Raises an error 'Operation is not allowed in read-only dataset.
}
procedure TZAbstractRODataset.RaiseReadOnlyError;
begin
  raise EZDatabaseError.Create(SOperationIsNotAllowed2);
end;
And the string referenced here is:

Code: Select all

SOperationIsNotAllowed2 = 'Operation is not allowed in READ ONLY mode';
Note that, internally, ReadOnly is called RequestLive, which acts in reverse way. RequestLive True means ReadOnly False and vice-versa. Two internal functions of TAbstractRODataset do that conversion:

Code: Select all

{**
  Gets the ReadOnly property.
  @return <code>True</code> if the opened result set read only.
}
function TZAbstractRODataset.GetReadOnly: Boolean;
begin
  Result := not RequestLive;
end;

{**
  Sets a new ReadOnly property.
  @param Value <code>True</code> to set result set read-only.
}
procedure TZAbstractRODataset.SetReadOnly(Value: Boolean);
begin
  RequestLive := not Value;
end;
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Terence
Zeos Dev Team
Zeos Dev Team
Posts: 141
Joined: 22.09.2005, 14:11
Location: Stuttgart
Contact:

Post by Terence »

ok, tx for detailed help ;)
fabian
Post Reply