Pages

Tuesday, April 26, 2022

View Job Queue Info from SQL - IBM i

Job Queue

Dealing with Job Queues (JOBQ) is part of day to day life when working with IBM i. There comes many situations where we need to check if a JOBQ is Held or Released, Which subsystem the JOBQ is attached to, No of active/held/released/scheduled jobs in JOBQ, Maximum number of active jobs etc. 

Different commands (WRKJOBQ, WRKJOBQD, WRKSBSD) are available to view this information. 

There is another easier way to access this information is by using SQL view JOB_QUEUE_INFO in QSYS2 (system name - JOBQ_INFO). 

One thing to note is, User should either have read authority to the JOBQ or have one of the special authorities *JOBCTL, *SPLCTL.

This view is helpful in many different ways like, 
  • List of Job queues present in a library. 
  • List of Job queues HELD/RELEASED in a library.
  • Retrieve Subsystem a JOBQ is attached to. 
  • List of Job queues in a Subsystem. 
  • Retrieve maximum number of active jobs in a Job queue. 
  • Retrieve number of Active/Held/Released/Scheduled jobs in a Job queue. 
E.g.:

List of Job queues present in a library. 

SELECT * FROM QSYS2/JOB_QUEUE_INFO WHERE JOB_QUEUE_LIBRARY = 'PREDDY'

List of Job queues HELD/RELEASED in a library.

SELECT * FROM QSYS2/JOB_QUEUE_INFO WHERE JOB_QUEUE_LIBRARY = 'PREDDY' AND JOB_QUEUE_STATUS = 'RELEASED'

Retrieve Subsystem a JOBQ is attached to. 

SELECT SUBSYSTEM_NAME, SUBSYSTEM_LIBRARY_NAME FROM QSYS2/JOB_QUEUE_INFO WHERE JOB_QUEUE_LIBRARY = 'PREDDY' AND JOB_QUEUE_NAME = 'TESTJOBQ'

List of Job queues in a Subsystem. 

SELECT * FROM QSYS2/JOB_QUEUE_INFO WHERE SUBSYSTEM_NAME = 'TESTSBS' AND SUBSYSTEM_LIBRARY_NAME = 'PREDDY'

Retrieve maximum number of active jobs in a Job queue. 

SELECT MAXIMUM_ACTIVE_JOBS FROM QSYS2/JOB_QUEUE_INFO WHERE JOB_QUEUE_LIBRARY = 'PREDDY' AND JOB_QUEUE_NAME = 'TESTJOBQ' 

Retrieve number of Active/Held/Released/Scheduled jobs in a Job queue. 

SELECT ACTIVE_JOBS, HELD_JOBS, RELEASED_JOBS, SCHEDULED_JOBS FROM QSYS2/JOB_QUEUE_INFO WHERE JOB_QUEUE_LIBRARY = 'PREDDY' AND JOB_QUEUE_NAME = 'TESTJOBQ' 

In addition to these number of active/held/released/scheduled job information by priority can be found. 

Below are the important columns present in this view. 

JOB_QUEUE_NAME (JOBQ) - The name of the job queue.

JOB_QUEUE_LIBRARY (JOBQ_LIB) - The name of the library that contains the job queue.

JOB_QUEUE_STATUS (STATUS) - The status of the job queue. HELD (The queue is held), RELEASED (The queue is released)

NUMBER_OF_JOBS (JOBS) - The number of jobs in the queue.

SUBSYSTEM_NAME  (SUB_NAME) - The name of the subsystem that can receive jobs from this job queue. Contains the null value if this job queue is not associated with an active subsystem.

SUBSYSTEM_LIBRARY_NAME (SUBLIB_NAM) - The library in which the subsystem description resides. Contains the null value if this job queue is not associated with an active subsystem.

SEQUENCE_NUMBER (SEQNO) - The job queue entry sequence number. The subsystem uses this number to determine the order in which job queues are processed. Jobs from the queue with the lowest sequence number are processed first. Contains the null value if this job queue is not associated with an active subsystem.

MAXIMUM_ACTIVE_JOBS (MAX_JOBS) - The maximum number of jobs that can be active at the same time through this job queue entry. A value of -1 indicates *NOMAX, no maximum number of jobs is defined. Contains the null value if this job queue is not associated with an active subsystem.

ACTIVE_JOBS (ACT_JOBS) - The current number of jobs that are active that came through this job queue entry. Contains the null value if this job queue is not associated with an active subsystem.

HELD_JOBS (HELD_JOBS) - The current number of jobs that are in *HELD status. 

RELEASED_JOBS (RLS_JOBS) - The current number of jobs that are in *RELEASED status. 

SCHEDULED_JOBS (SCHED_JOBS) - The current number of jobs that are in *SCHEDULED status. 

TEXT_DESCRIPTION (TEXT) - Text that describes the job queue. Contains the null value if there is no text description for the job queue.

OPERATOR_CONTROLLED (OPR_CTRL) - Whether users with job control authority are allowed to control this job queue and manage the jobs on the queue. Users have job control authority if SPCAUT(*JOBCTL) is specified in their user profile. *NO - This queue and its jobs cannot be controlled by users with job control authority unless they also have other special authority. *YES - Users with job control authority can control the queue and manage the jobs on the queue.

AUTHORITY_TO_CHECK (ALL_AUTH) - Whether the user must be the owner of the queue in order to control the queue by holding or releasing the queue. *DTAAUT - Any user with *READ, *ADD, or *DELETE authority to the job queue can control the queue. *OWNER - Only the owner of the job queue can control the queue.


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

No comments:

Post a Comment

View Job Queue Info from SQL - IBM i

Job Queue Dealing with Job Queues (JOBQ) is part of day to day life when working with IBM i. There comes many situations where we need to ch...