How to release lock on a record in RPG/400

11260 pts.
What type of opcodes should I use to release the lock on a record?

Answer Wiki

Thanks. We'll let you know when a new response is added.


The following opcodes should release locks on records.



Martin Gilbert.


The problem with the lists above and in the Discussion below is that some of the op-codes are from RPG IV and not RPG/400.

For RPG/400, the corrections are EXCPT, UNLCK, UPDAT and COMIT.


Discuss This Question: 10  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Birddon
    It used to be a standard interview question, Name 7 ways to release a record lock in RPG. READ (READE READP) CHAIN CLOSE UNLOCK UPDATE EXCEPT (for the file) SETLL (SETGT SETLT)
    45 pointsBadges:
  • Gilly400
    Hi, The READ, CHAIN and SETLL don't necessarily unlock records, especially not if you're using commitment control. Regards, Martin Gilbert.
    23,730 pointsBadges:
  • GAC
    ... if you are using commitment and want to release the record(s) use COMMIT ... But I have experienced that it does not work under some circumstances. :-o
    300 pointsBadges:
  • Yorkshireman
    You need to look in the manual relevant to the language you are using. The issue of when a lock is created, or not, is dealt with fully, precisely, and definitively by the IBM authors who write these things. Check the DB2 programming and the RPG or RPGLE manuals
    6,085 pointsBadges:
    Does WRITE lock up that record? 
    235 pointsBadges:
  • jpanzenhagen
    WRITE does not put a lock on a record.
    95 pointsBadges:
  • ToddN2000
    A WRITE will not lock a record. A CHAIN locks a record... I have run across many old programs, old like RPGII and RPGIII, that used a CHAIN to validate data with a file. If that is all you are doing and you get locks on this record, it is better to use the opcode (not sure when this came out, but use CHAIN(N). This does the chain but with a no lock option.
    136,240 pointsBadges:
  • GregManzo
    If you are only validating the key exists, then CHAIN(N) or SETLL both work - SETLL is marginally faster but you don't get the contents of the record.
    A WRITE will lock the new record *if* you are using commit control - and if you aren't then why not? If you are serious about data integrity then you should be making a 'commitment' to your database. :-) but be aware of the differences between an ODP record lock and a commit lock.
    2,970 pointsBadges:
  • WoodEngineer
    Are you asking about a record locked by your program or a lock created by another program?
    8,235 pointsBadges:
  • TheRealRaven
    Without knowing the circumstances of the lock, there's no good way to answer. WoodEngineer is on a good track there.
    36,880 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: