I have developed a component, that has a prepared Query-component to
retrieve data fast from a table in a fixed format. I use this for
history data, so the component has a function like
Load(firstTime, lastTime): TDataset
begin
...
Query.SetParamByName(...
Query.Open;
result := Query;
end
The component uses the Query to get the data between the given times.
I return the Query as a result, so that whoever uses the component can
browse the result set as he likes. But there are two drawbacks:
1. The query is accessible outside the component and can be freed
accidentally.
2. It is not possible to ask two result sets and use them at the same
time, because the previous result set is lost each time Load is called.
I have no idea, how I could clone the query, so that I could return a
new copy of the dataset. This might be a bad idea anyway. It might
be better to give your own dataset for the Load-method, which would
then fill it with the query results. But how do I do this? I want to
use a predefined Query, so that I can Prepare the SQL-statement. If
I use a different Query-component every time, I lose this benefit. Any
suggestions?
Jouni Aro
Prosys PMS Oy