HReadSeekLast behaviour

Startbeitrag von Arie am 09.07.2013 10:59

Hi,
Have a look at the floowing data

AutoID EmployeeID Date StartTime EndTime
5633 301 2013-07-01 12:54
5594 301 2013-07-01 11:10 12:45
5537 301 2013-07-01 09:06 10:54

I'm using a HReadSeekLast(timetable,compkey_empid_date, [301,'2013-07-01'])
(actually the dates are regular date field, but shown here as text for readability)

I was expecting to get the record LAST added, autoID=5633
But in return I get the SECOND last , at least according to the autoid field: 5594

I also used HF-controlcentre which shows a real REC#. In my case it is equal to the value of my autoID field. (most probably I never delete records from this file)

Where do I go wrong? Maybe I misunderstand the behaviour of HReadSeekLast?

Antworten:

Hi Arie,

of course, there's some misunderstanding. It's a set of records with the same key, there's no god-given sort sequence and no, HyperFile doesn't record the sequence of record insertion.

HReadSeekFirst points to the first record in this subset of records in the file
HreadNext or HReadPrevious will present the next / previous record within the set of records
HReadSeekLast points to the last record in this subset

The whole mechanism guarantees only that HReadNext / HReadPrevious will neither omit a record nor present a duplicate one.

Bottom line: if you want to have a certain sequence then you should build a composite key which reflects the insertion sequence. Instead of keeping a number on the central server which every PC has to fetch, just synchronize all PCs in the network with the correct time and build a composite key of sysdate + systime, the sequence will be automatically correct. For getting the correct date + time from the web: http://www.windev.at/wp_de/?page_id=388

von GuenterP - am 09.07.2013 11:16
Thans Guenter,

you are right. The sort order in SQL is "undefined" if we do not tell the engine to use one.
But why use a insertion-seqeunce of your own? In my case I can use the autoID. Or not? I'm not particular interested in the exact insertiontime.

von Arie - am 09.07.2013 11:40
Quote
Arie Mars
Thans Guenter,

you are right. The sort order in SQL is "undefined" if we do not tell the engine to use one.
But why use a insertion-seqeunce of your own? In my case I can use the autoID. Or not? I'm not particular interested in the exact insertiontime.


Hi Arie,

I wouldn't put a lot of trust in the Auto-ID. Personally, I do not trust it at all! We're using either GUIDs (in your case not applicable) or programmatically composed keys (simple ANSI strings) which would work here.

von GuenterP - am 09.07.2013 13:58
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.