From: Chris Demoss To: All
Is there a Catch-22 to record locking in RPG? I'm trying to correct a bug in a program that is consistently reporting a record lock error under certain circumstances when it should be reporting a record not found.
As an example, assume Terminal B has a lock on key 256 of an indexed file, and that key 255 does not exist. When Terminal A at-tempts to access key 255, using a READ or READE with both an EOF indicator and an error (record lock) indicator, the record lock indicator comes on even though 255 doesn't exist. I can't defer the check of the error indicator until after I have tested for record found because the EOF indicator doesn't function (i.e., no data is read in) when the error indicator is turned on. Tell me there is a way to do this without doing two reads-that is, checking for record existence first and for a record lock second. Any clues?
From: Matt Sargent To: Chris Demoss
The reason this happens on a READ is obvious. It's going to attempt to read the next record in the file, which will be 256 if 255 isn't there. As for the READE, it may be that the record must be accessed before it can determine if it matches the key value (I'm guessing here).
Something you might look at is whether you really need to do a read-for-update at the point you're having problems. If not, place an N in the half-adjust position on the READ or READE; the program will simply read the record without trying to gain a lock on it. Of course, you won't be able to update, but if you're only loading a subfile or something like that, it doesn't matter.
From: Chris Demoss To: Matt Sargent
It is true that a READE on an update file checks to see whether the record is available before it matches it up to factor 1. As to the "read-no-lock" option, I am doing that in one of my update programs for this file, which does in fact dump out records to a subfile. But the other is a simple one-record input-update operation, and-while I prefer not to have to read without locking and rechaining prior to update-that seems like the only route.
LATEST COMMENTS
MC Press Online