× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



One solution would be to write the records, without a sequence number, to a data queue and write a small program that has the sole function of creating the correct sequence number and writing the record to the physical file.


On 8/11/2014 3:58 PM, Vinay Gavankar wrote:
Hi,

I have a logical file with an Id and Sequence number as a Unique key. The
first record for an Id is written with Seq No. as 99999 and subsequent
records are to be written with (current lowest sequence - 1).

There is only one program that is writing to this file, but is running
concurrently.

What would be a fool-proof way of writing to the file without having to
trap for error on write and looping.

For example, when getting the lowest sequence, I can keep that record
locked, and then write a record with a lower sequence and then unlock the
file.

But if another instance of the program hits the same Id at the same time
when the record is locked, it will wait for those microseconds for the lock
to be released, but once the lock is released, wouldn't it get that record,
instead of the the one that was written with a lower sequence number? In
which case, it would end up with duplicate sequence number when it tries to
write a record.

Is my understanding of what would happen wrong?

Would it make any difference if I were to use Setll & read instead of a
Chain to get to the lowest sequence number?

TIA for any suggestions.

Vinay


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.