Wednesday, March 31, 2021

Check locks on IFS Objects from SQL - IBM i

IFS Object Locks

Identifying locks or references on IFS Objects become essential at times. This can be done by calling API QP0LROR (Retrieve Object References). 

The same information can be retrieved from SQL by using table function IFS_OBJECT_LOCK_INFO. 

This function accepts two parameters (Path name and Ignore errors). 

Path Name (PATH_NAME) - Path name for which the locks or references are to be retrieved. This could be a directory or stream file. This is a mandatory parameters. 

Ignore Errors (IGNORE_ERRORS) - YES or NO to be passed to determine what needs to be done when an error is encountered. This is an optional parameter and YES would be considered if no value passed. 
  • YES (Default) - A warning is returned and no row would be returned incase of an error.  
  • NO - An error is returned.

This function can be called to check the locks on a directory

IFS Object locks from SQL - IBM i

Or, by passing a stream file. 

IFS Objects locks from SQL - IBM i

Optionally we can pass Ignore errors 'NO' if the error is to be returned in case of any errors (like Invalid directory or stream file). 

Below are the few important columns returned. 
  • PATH_NAME - Full path name of an object.
  • JOB_NAME - Job name holding the lock or reference. 
  • RO_COUNT - Number of read only references for this job.
  • WO_COUNT - Number of write only references for this job.
  • RW_COUNT - Number of read and write references for this job. 
  • XO_COUNT - Number of execute only access references for this job. 

There are many other columns returned by this function and full list of columns can be found here

*This function is only available since IBM i 7.3 TR7 and IBM i 7.4 TR1. 

If you have any Suggestions or Feedback, Please leave a comment below or use Contact Form. 

No comments:

Post a Comment

Different Ways of Sorting Data in a List - Python

Sorting Data in a List List is a collection of data (of different data types), much like an array. Like any data structure or data set, dat...