Welcome! Log In Create A New Profile

Advanced

[WB24]HReadSeekFirst on unknown value

Posted by ericus 
[WB24]HReadSeekFirst on unknown value
April 24, 2020 09:12AM
Good day

Can someone please assist on what index to create and/or what search to use to find this record:

I have a table with vehicle registration numbers and start and end odo readings.

I want to find the last reading for a specific vehicle so I created an index on vehicle registration number and odo reading descending.

How to find the record if you don't have the last odo reading? I would have preferred not to use HExecuteSQLQuery as I think it might take to long.

Thanks in advance


Ericus Steyn
Argus
Re: [WB24]HReadSeekFirst on unknown value
April 24, 2020 04:25PM
this should work:

//This first line will never find a value
hreadseek(MyFile,MyCompositeKey,[VehiculeRegistration,MAXTECHNICALLYPOSSIBLEODOREADING])
//but it will position the pointer in the file just AFTER your last record (the one you are looking for), so
hreadprevious(MyFile,MyCompositeKey)//SHOULD read your record, if it exists

//Finally, a test on VehiculeRegistration will verify that you are indeed on your desired record
Re: [WB24]HReadSeekFirst on unknown value
April 28, 2020 11:38AM
Thanks for the reply Argus but it does not seem to work on my side.

I changed it to a query and it is actually very fast so I'm happy.

Regards
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: