Created
June 4, 2022 15:23
-
-
Save forstie/20fca8f4d2c989875bfca869e56110c4 to your computer and use it in GitHub Desktop.
The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it.
This file contains 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
-- | |
-- Subject: The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it. | |
-- Author: Scott Forstie | |
-- Date : June, 2022 | |
-- Features Used : This Gist uses QSYS2.ACTIVE_JOB_INFO, BOOLEAN, QSYS2.QCMDEXC scalar function, CTE, case expression | |
-- | |
-- | |
-- Is the DDM/DRDA listener active? (If at IBM i 7.4 or earlier) | |
-- | |
select count(*) as DDM_DRDA_Listener_Active | |
from table ( | |
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN') | |
); | |
stop; | |
-- | |
-- Is the DDM/DRDA listener active? (If at IBM i 7.5 or later) | |
-- | |
select boolean(count(*)) as DDM_DRDA_Listener_Active | |
from table ( | |
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN') | |
); | |
stop; | |
-- | |
-- Restart the *DDM TCPSVR as needed (If at IBM i 7.4 or later) | |
-- | |
with ddmsvr (started) as ( | |
select count(*) as DDM_DRDA_Listener_Active | |
from table ( | |
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN') | |
) | |
) | |
select | |
case started | |
when 0 then qsys2.qcmdexc('QSYS/STRTCPSVR SERVER(*DDM)') | |
else 1 | |
end | |
from ddmsvr; | |
stop; | |
-- | |
-- Restart the *DDM TCPSVR as needed (If at IBM i 7.5 or later) | |
-- | |
with ddmsvr (started) as ( | |
select boolean(count(*)) as DDM_DRDA_Listener_Active | |
from table ( | |
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN') | |
) | |
) | |
select | |
case started | |
when false then qsys2.qcmdexc('QSYS/STRTCPSVR SERVER(*DDM)') | |
else 1 | |
end | |
from ddmsvr; | |
stop; | |
-- | |
-- Is the DDM/DRDA server active? | |
-- | |
select subsystem, count(*) as QRWTSRVR_Jobs | |
from table ( | |
qsys2.active_job_info(JOB_NAME_FILTER => 'QRWTSRVR') | |
) | |
group by subsystem; | |
stop; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment