Start of change

QCMDEXC scalar function

The QCMDEXC scalar function executes a CL command.

Authorization: Any authority requirements for the CL command apply to the use of this function.

Read syntax diagramSkip visual syntax diagram QCMDEXC ( COMMAND =>  command )
The schema is QSYS2.
command
A character string containing a CL command. The maximum length is 32000 characters.
The result of the function is an integer. If the command is successful, the function returns a value of 1. If the command execution fails, the function returns a value of -1.

Example

Hold any jobs that started running an SQL statement more than 2 hours ago.

SELECT JOB_NAME,  
       CASE WHEN QSYS2.QCMDEXC('HLDJOB ' CONCAT JOB_NAME) = 1 THEN 'Job Held'
            ELSE 'Job not held'
         END AS HLDJOB_RESULT
  FROM TABLE (QSYS2.ACTIVE_JOB_INFO (DETAILED_INFO=> 'ALL'))
  WHERE SQL_STATEMENT_START_TIMESTAMP < CURRENT TIMESTAMP - 2 HOURS;
End of change