RPG Record Locking

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: