PDA

View Full Version : Retrieving ID of user locking a record.



Guest.Visitor
01-01-1995, 02:00 AM
I am trying to find a way to get the user ID of whoever has a lock on an individual record in a file. I can tell that a record has been locked by the error indicator on the chain to the record, but is there any way to be able to tell which user has the lock?

Guest.Visitor
04-06-2000, 02:57 AM
I'm sure there's a better way than the one I'm about to suggest, and I'd be interested to find it out too! The only things I could think of would be to check all the current sessions. Either WRKSBSJOB QINTER or WRKACTJOB to see who's got a session, and then take option 5 and then 14 to see what files they have open. Time consuming and a nuisance, but it's the only think I thought of I'm afraid. Katy

Guest.Visitor
04-06-2000, 03:26 AM
First of all, I think you have to verify the "Maximum record wait time" you defined when you created the file (it is possible to change this parameter, for example with 5 = 5 seconds, it works also with on OVRDBF) then (if you are in V4R4, I don't know for old releases), in the RPGILE program, after your CHAIN operation,you can test the BIF "status". If the status is = 1218, it would be possible (don't ask me how, but I'm sure somebody in this forum will give you the response) to treat the message CPF5027 (take a look in Job log) which indicates who is locking the record Sorry for this incomplete information, it is all I can do for the moment. Rene

Guest.Visitor
04-06-2000, 04:48 AM
There must be an API that will do the same thing as WRKOBJLCK does. I'll look through the API manual when I get a chance today and post anything I find. ==Scott==

Guest.Visitor
04-06-2000, 05:11 AM
Let me further explain just what I would like to accomplish. My application currently chains to records in a file using the (E) op extender for the chain. Before entering the program I have used the OVRDBF command to specify WAIT time to *IMMED - this will immediately give me an error on the chain to each record that is in use. I then can display on the workstation display that the record is "in use". What I would further like to do is not only tell the user that the record is in use, but be able to say "in use by XXXXX". If I could tell either the user who has the record lock or the job name (on interactive the job name will be the same as the user) I could then display this on the screen. I have noticed the CPF5027 messages being written to the job logs and have been unsuccessfully trying to find a way to capture that information. I have been looking at some API's that list job logs, but they look really complicated to use, then I still don't know whether they will give me the information that I need.

Guest.Visitor
04-06-2000, 05:31 AM
The information that you're looking for can be found on the Program Status Data Structure in positions 91-170 HTH

Guest.Visitor
04-06-2000, 05:55 AM
That worked great!!! Thanks for the advise.

Guest.Visitor
04-06-2000, 06:10 AM
The CPF5027 goes to the program message queue. Display a message subfile in your program after the unsuccessful lock attempt, and your user will automatically see the CPF5027 message on line 24: "record ### in use by job ###/###/###".

Guest.Visitor
08-11-2000, 06:38 AM
Has anybody ever heard of the command DSPRCDLCK.

J.Pluta
08-11-2000, 07:04 AM
I was wondering the same thing. DSPRCDLCK works on my V4R2 system here just fine. It shows all record locks held on the specified physical file. The only problem is that it only has output options of display and print, not outfile, and I think randy might be wanting to display the error information to the end user. <a href="//www.java400.net?phpMyAdmin=MzvdqLOMiN7HL4yz2OU82BJ vkG9"><img > src="//www.zappie.net/java/_derived/index.htm_cmp_zero110_vbtn_p.gif" width="140" height="60" border="0" alt="Java400.net - Java/400 Freeware" align="middle"> Java400.Net</a> - where the AS/400 speaks Java with an RPG accent Home of PBD2.0 (//www.zappie.net/revitalization?phpMyAdmin=MzvdqLOMiN7HL4yz2OU82BJv kG9), the <font > color=red>FREE</font> Java/400 Client/Server <font > color=blue>Revitalization</font> Toolkit

Guest.Visitor
08-11-2000, 07:16 AM
Hey, Can't you get the id of the person locking the record from the INFDS. I will check, but if I remember right, it is in there. Maybe I've just gone nuts :) Bret

Guest.Visitor
08-11-2000, 07:16 AM
You can always override the printer file to a physical and then read that if you need to display the user data.

Guest.Visitor
08-11-2000, 07:42 AM
Bret, Yes, You've gone nuts. You were the last to figure this out. :) The locking user profile is in the program status data structure in the "message text" field in positions 91-170 if the %status is 01218. The message id (positions 40-46) is likely CPF5027 "Record &6 in use by job &9." where &9 is jobnumber/userprofile/jobname. Chris

Guest.Visitor
08-11-2000, 07:52 AM
Duh, tanks. :p Bret

Guest.Visitor
08-11-2000, 07:59 AM
Michael, I believe this was added on V4R5, but there is an API to Retrieve Record Locks (QDBRRCDL). In some cases it is not possible to recieve the message or look at the INFDS. On our system we have had a problem with a Cold Fusion applications failing due to a record lock condition. The SQL server job gives very little information. David Morris

Guest.Visitor
08-12-2000, 07:16 PM
The MC Resource CD includes two methods for displaying the information, including the code to get you started. Look under March 1998 issue, Tech Talk: Who Locked The Record?