Last active
November 13, 2023 19:39
-
-
Save sriedmue79/40ef631196d32ed1226af18f451ee24b to your computer and use it in GitHub Desktop.
IBM i - Various uses for the ACTIVE_JOB_INFO() table function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------------------------------------------- | |
-- Description: Various uses for the ACTIVE_JOB_INFO() table function | |
--------------------------------------------------------------------- | |
--Description: check whether a job (by job name) is currently active in a particular subsystem | |
SELECT JOB_NAME | |
FROM TABLE ( QSYS2.ACTIVE_JOB_INFO( JOB_NAME_FILTER => :JobName, | |
SUBSYSTEM_LIST_FILTER => :SubsystemName ) ); | |
--Description: Jobs in a subsystem that are in a specific status | |
SELECT * | |
FROM TABLE ( QSYS2.ACTIVE_JOB_INFO( SUBSYSTEM_LIST_FILTER => :SubsystemName ) ) | |
WHERE JOB_STATUS=:JobStatus; | |
--Description: Netserver jobs | |
SELECT * FROM TABLE ( QSYS2.ACTIVE_JOB_INFO( SUBSYSTEM_LIST_FILTER => 'QSERVER', | |
JOB_NAME_FILTER => 'QZLSFILE*' ) ); | |
--Description: active jobs that came from a specific JOBQ (give the "subsystem list filter" to make this run in a reasonable time) | |
SELECT * | |
FROM TABLE ( QSYS2.ACTIVE_JOB_INFO( DETAILED_INFO => 'ALL', | |
SUBSYSTEM_LIST_FILTER => :SubsystemName ) ) | |
WHERE JOB_QUEUE_LIBRARY = :JobqLib | |
AND JOB_QUEUE = :JobqName; | |
--Description: how many jobs are active in each subsystem? | |
SELECT SUBSYSTEM, COUNT(1) AS JOBCOUNT | |
FROM TABLE ( QSYS2.ACTIVE_JOB_INFO() ) | |
GROUP BY SUBSYSTEM | |
ORDER BY COUNT(1) DESC; | |
--Description: all active jobs, sorted by subsystem | |
SELECT * | |
FROM TABLE ( QSYS2.ACTIVE_JOB_INFO() ) | |
ORDER BY SUBSYSTEM; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment