Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique key based on timestamp
Message
From
18/10/2004 12:37:08
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00952187
Message ID:
00952324
Views:
8
>I want to create a unique record key that is based on timestamp. So when I sort the records on this key, they are sorted in datetime order.
>
>Any ideas how to create this unique key? Would like it to not be a date field, and to be as precise as possible, and as short in length as possible.
>
>Realize that I will have to check for duplicate key prior to inserting a new record as that two records quickly inserted might get a duplicate key.
>
>vfp 6.0.
>
>Thanks
>
>Brenda

Brenda,

A datetime field or a ttoc(datetime(),1) value will be problematic in a multi user environment or if more than 1 record is inserted at the same second (or is that millisecond, whatever) as it will yield duplicates. It would probably be best to use an autoinc field or a combination of datetime field and an autoinc field to sort the records in datetime order. The autoinc field would increment and place the records in the order that they were inserted. It the datetime value is not the datetime of record insertion, you would need ot use a datetime field to order records by datetime and the autoinc field would be your unique primary key. When querying you could order by the appropriate fields ir if an indexed order is desired, you could create an index by converting and concatenating the sort fields.
Previous
Reply
Map
View

Click here to load this message in the networking platform