Good point Buck. I hadn't thought past the timeout. Since the READ failed, the file cursor wouldn't advance past the locked record. You'd be stuck at that point.
Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxx> on behalf of Buck Calabro <kc2hiz@xxxxxxxxx>
Sent: Thursday, October 18, 2018 3:28 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Exclusive locks at the record level?
On Thu, 18 Oct 2018 at 01:14, Roger Harman <roger.harman@xxxxxxxxxxx> wrote:
Another process trying to read that record will wait until the timeout (WAITRCD value on the file) and then throw a message. Of course, you can monitor for that in the program.
Amplifying Roger's comment, I don't believe there is a 'read next
unlocked' operation in RPG RLA. Essentially, the proposed design would
do a READ and if the record is locked by a different process, the
program will get a read timeout exception. The program can, of course,
trap that error, but I don't see how the program can get past it -
issuing another READ will attempt to read the same, locked, record. If
all the processes READ using the same access path, the second one must
necessarily attempt to read an 'in use' record.
The last time I did this, I added a column to the table that indicated
if the row was 'in work'. Build a LF that omits these rows, and READ
through the LF. The program only sees rows that are available. The
first step is to set the 'in work' column.
--buck
As an Amazon Associate we earn from qualifying purchases.