Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating an index field
Message
From
09/11/2004 11:29:56
 
 
To
09/11/2004 09:08:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00959514
Message ID:
00959600
Views:
6
>>Hi All
>>
>>I have a table and for each record I want to execute a process and then store the datetime when the process for that record was completed.
>>
>>I also want to process the records in this same datetime order so that I can loop through all records and process each from the oldest record on file to the most current. So there is an index on that datetime field and which is set as the index to use for dropping through the file.
>>
>>Of course as soon as I update the first record with the current datetime it moves to the end of the index and the subsequent SKIP positions me at EOF.
>>
>>I cannot GO TOP since that would put the app in an endless loop. I want to process all the records once, from oldest update to latest udpate.
>>
>>I can store the update datetime into a second field and then go back over all records when the entire file is done and update the index datetime field with this second field but that would mean that a second instance of my app would not know the correct record to process next <g>
>>
>>Anybody had a similar situation with an elegant solution?
>>
>>Thanks
>
>Jos,
>
>
>Think this may work
>
>Before processing, you use the table order DateTimeField and store the recno() somewhere
>
>Before processing a record, save the record's datetime. Then process it and do a seek() with the saved datetime (to reposition)
>
>You continue processing as long as the recno() )is not equal to the one you saved before processing


Gregory, thanks for this idea. I modified it slightly. I create a cursor of record numbers and last update datetime and order it by the datetime value. I then drop through this cursor using record numbers to position the source file. If the last update datetime is the same then I know that another instance of my app has not processed this record yet. I then lock the record and process the update. Then update the datetime field. This allows for multiple instances of the update program to run and to be able to process the updates in the datetime update order :)

Thanks to you and Jim for the ideas.

Later
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform