RTC Forums
November 24, 2024, 07:46:41 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: search for a row in rtcdataset  (Read 4535 times)
lionheart
Newbie
*
Posts: 18


« 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;
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 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
Logged
lionheart
Newbie
*
Posts: 18


« Reply #2 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 Smiley.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 15 queries.