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?
TZReadOnlyQuery<>TZQuery
Moderators: gto, cipto_kh, EgonHugeist
TZReadOnlyQuery<>TZQuery
fabian
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
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
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: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
Code: Select all
{**
Raises an error 'Operation is not allowed in read-only dataset.
}
procedure TZAbstractRODataset.RaiseReadOnlyError;
begin
raise EZDatabaseError.Create(SOperationIsNotAllowed2);
end;
Code: Select all
SOperationIsNotAllowed2 = 'Operation is not allowed in READ ONLY mode';
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;