![view all jobs locking an object using sql](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisuIXN-tSxhiA8PDIbVd9Uz4H-CLs4rePo-U-McWOcMMD-mAdXHYzhk4EKZl8OR0ByCY_2TCTXiUuCJrg9bZcYgf7pksXa3l0HpoUIFioUmwvmG2jnd_HmEvxnZ7Kf2m74QbI7lRFkGhlh/s200/sql.png)
This is almost embarrassing. I was asked if there is an easy way to programmatically check if an object is being used by another job. I knew the name of the SQL View, but when I searched this site I could find I mentioned it when IBM i 7.2 TR3 was announced, but I did not write anything more about this View. Today I am making amends of that oversight.
The question was is it possible to know which users are using an object. I could just use the Work Object Lock command, WRKOBJLCK, at the command line:
WRKOBJLCK OBJ(MYLIB/TESTFILE) OBJTYPE(*FILE) |
But I needed to be able to retrieve within a program the same information.