how to find which record is locked…
That’s an unusual question since a program usually already knows which record it’s processing. However, you might be asking about SQL mass updates or some similar process that operates on sets of records. Can you explain why you asked?
how to release the lock by ourselves.
That’s easy. Run ENDJOB against the job that has the lock. Unless all of your programs are written to respond to requests from other jobs, ending the job that is holding the lock is your only option.
sir thanks everybody for answering my question.
i still have some doubts,if i’m accessing a record for updating and another user is also trying to access the same record for updating at the same time,that record would be locked no at that time what he shall do to release the lock or has he has to wait till i finish updating,wrkobjlck command what it is used for.thanks gentlemen in advance.
Whenever possible, instead of ending any jobs, locate the record lock user ask them to complete the update and explain what adverse affect it has on the system and other users when a record is left open. Once the record is updated and released for another transaction, you may need to reply to an object lock message if the program(s) requires this. Normally, entering a retry will work but you will want to check with your developer’s for valid replies to ensure successful processes.
We have found that as we educate our users rearding this locking situation, our locking errors have decreased substantially.
Is this an interactive job? On interactive jobs… sometimes a developer will not relases a record prior to returnig a display of that record to the enduser. The record is locked… the enduser is in “think time”… not knowing that while he/she is thinking… the record is locking others from updating. The application needs to verify that during the user “think time”… that the record may have been updated. And needs to be redisplayed for verifcation. Make sense?
if i’m accessing a record for updating and another user is also trying to access the same record for updating at the same time,that record would be locked no at that time
That is correct.
what he shall do to release the lock or has he has to wait till i finish updating,
We can’t tell what a user has to do to release a lock because we don’t know what programs are being used. In general, programs would be written to allow some kind of exit or cancellation. Usually, the F12 key would start a cancellation, but that is determined by how the developer wrote the programs.
wrkobjlck command what it is used for.
The WRKOBJLCK command is used when you want to check to see if an object has any locks associated with it. It tells you what kinds of locks have been set and which jobs have those locks. The command isn’t used in programming much. It is generally used by administrators during investigation of problems.
When an RPG program runs into a lock condition, you can retrieve information about the lock from a number of sources. The sources will depend on how you coded the program.
For example, if you coded for a file information data structure (INFDS) and a program status data structure (PSDS), you could check the *STATUS to see if it was ’01218′. You could check the exception data in the PSDS to find out about what job held the lock. That information could be displayed to the user.
A trivial example of one way to catch lock errors (see figure 132)… some information on the file information data structure (INFDS)… and info on the program status data structure (PSDS)…