RTC Forums

Subscription => Support => Topic started by: lionheart on November 27, 2011, 10:48:22 PM



Title: search for a row in rtcdataset
Post by: lionheart on November 27, 2011, 10:48:22 PM
Is there any tricks or fast search for a row in RtcDataSet ? What i do now is to iterate through rows until found or EOF.

Quote
rtcdataset.first
while not rtcdataset.eof do begin
  if rtcdataset.asvalue['id'] = valuetofind then begin
    ...
    ...
    break;
  end;
  rtcdataset.next;
end;


Title: Re: search for a row in rtcdataset
Post by: D.Tkalcec (RTC) on November 27, 2011, 11:29:08 PM
There is no "Find" method on TRtcDataSet. Iterating through the dataset is the only way to find a record based on field values.

PS. Even if there was a "Find" method on TRtcDataSet, it would also have to itterate through all rows in the dataset to find a specific row, since rows aren't indexed for searching. And ... a custom implementation (your own code) written to accomodate your specific needs will usually be faster than a standard "Find" method, so there would be no real benefit (except for not having to write the code yourself) if there was a "Find" method on the TRtcDataSet class.

Best Regards,
Danijel Tkalcec


Title: Re: search for a row in rtcdataset
Post by: lionheart on November 28, 2011, 06:55:56 AM
Thanks and no problem. I was asking to ensure i didn't miss any tricks on the subject :).