Add API_SQL

This commit is contained in:
SJLennon
2021-08-24 15:29:30 -04:00
parent 83cd96240c
commit 82180c4408
16 changed files with 525 additions and 7 deletions
+50
View File
@@ -0,0 +1,50 @@
# Using IBM [Work Management Services](https://www.ibm.com/docs/en/i/7.4?topic=services-work-management)
IBM has begun providing access to APIs using SQL. The code here uses the QSYS2.OBJECT_LOCK_INFO SQL view. It is shorter and simplified code that can be used to replace that in [APIs which returns users who have a lock on an object](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs).
## GETOBJUSR.CMD
This command is the top level interface. It is unchanged from the version in [APIs](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs), but it provided here for completeness.
Prompted, it looks like this:
![GetObjUsr Prompt](Images/GetObjUsr_1.jpg)
You specify the object and type and the command returns information on the locks on the object. You can return a file of objects and/or a message.
The returned file is GETOBJUP in QTEMP.
The returned message would be suitable for sending to the operator and look something like one of these:
![GetObjUsr Message](Images/GetObjUsr_2.jpg)
![GetObjUsr Message](Images/GetObjUsr_3.jpg)
It shows the details of up to 4 jobs and lists how many additional jobs, if any, have locks.
The job name can be copied and pasted into a WRKJOB command, e.g. `wrkjob 233920/LENNONS/QPAD151018`.
## GETOBJUP File
If requested, this file is created in QTEMP. The contents would look like this:
![GetObjUsr Message](Images/GetObjUsr_4.jpg)
## GETOBJUC.CLLE
This is the command processing program for the GETOBJUSR command. It does some housekeeping and calls GETOBJUR. Unlike the version in [APIs](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs), it does not need to create QTEMP.GETOBJUP.
## GETOBJUR.SQLRPGLE
This creates QTEMP/GETOBJUP if requested, using SQL. Then it retreives the job name using the QSYS2.OBJECT_LOCK_INFO view, and orders it by job name. It populates file GETOBJUP using SQL.
This about 100 lines shorter and it does not need the SRTUSRSPC program.
## T0/T1/T2/T3.CLLE
These are simple CL programs to test GETOBJUSR and display the results by sending a message and/or displaying the QTEMP/GETOBJUP file.
## T9xxx.CLLE
More complex testing:
- Call T9ALLOCMNY to create a interactive lock and several batch locks on QIWS/QCUSTCDT.
- Then call T9DSPMNY to display the locks.
- T9ALLOC1 creates a lock on QIWS/QCUSTCDT. It is called by T9ALLOCMNY.