ADMIN_TASK_STATUS table function

The ADMIN_TASK_STATUS function returns a table with one row for each task that is defined in the administrative task scheduler task list. Each row indicates the status of the task for the last time it was run.

Optionally, if you specify the max-history parameter, the function returns a row of data for each execution of a task (up to the max-history value). For tasks that have not been executed, this function returns a row of data with a NULL status.

Authorization

The user who calls this function must have MONITOR1 privilege.

Read syntax diagramSkip visual syntax diagramADMIN_TASK_STATUS(max-history)

The schema is DSNADM.

max-history
Specifies the maximum number of execution statuses per task to be returned. The most recent execution statuses are returned.

If the parameter is set to NULL, all available task execution statuses are returned. If the parameter is set to 1, only the status for the last time the task was run is returned, which is the same result as not specifying this option. This is an input parameter of type INTEGER.

The result of the function is a table with the format shown in the following table.
Table 1. Format of the resulting table for ADMIN_TASK_STATUS
Column name Data type Contains
TASK_NAME VARCHAR(128) Contains the name of the task that has run, is running, or has been bypassed.
STATUS VARCHAR(10) Contains one of the following values that indicates task status:
RUNNING
The task is currently running
COMPLETED
The task has finished running.

For asynchronous tasks (JCL jobs), this column contains COMPLETED whenever the job is submitted to be run. Otherwise, this column contains COMPLETED only after the task has finished running.

NOTRUN
The task was not run at the scheduled invocation time. The MSG column contains the error or warning message that indicates why the task was not run.
UNKNOWN
The scheduler shut down while the task was running. The scheduler is started again but cannot know the execution status of this interrupted task.
NUM_
INVOCATIONS
INTEGER Contains the number of times the administrative task scheduler attempted to run the task, including the current time if the task is currently running. The values in this column does not indicate if the task was successfully run.
START_
TIMESTAMP
TIMESTAMP Contains the time when the task started running if the STATUS column contains COMPLETED, RUNNING, or UNKNOWN. Otherwise, this column contains the time that the task should have started to run but could not.
END_
TIMESTAMP
TIMESTAMP Contains the time when the task finished running.
JOB_ID CHAR(8) Contains the job ID that is assigned to the JCL job submitted by the administrative task scheduler. This column contains NULL if the task is a stored procedure or if the STATUS column does not contain COMPLETED.
MAXRC INTEGER Contains the highest return code from submitting a JCL job. If the task is synchronous, the value in this column is changed to the return code that is returned when the job finishes running.

This column is set to NULL if the task is a stored procedure, if the STATUS column does not contain COMPLETED, or if a synchronous task is finished and has run with JES3 in a z/OS® 1.7 or earlier system.

COMPLETION_
TYPE
INTEGER Contains one of the following values that indicates the completion type of the JCL job submitted by the administrative task scheduler:
0
No completion information
1
Job ended normally
2
Job ended by completion code
3
Job had a JCL error
4
Job was canceled
5
Job abended
6
Converter abended while processing the job
7
Job failed security checks
8
Job failed in end-of-memory

This column contains NULL if the task is a stored procedure, if the STATUS column does not contain COMPLETED, or if the JCL job is run with JES3 in a z/OS 1.7 or earlier system.

SYSTEM_
ABENDCD
INTEGER Contains the system abend code returned by a failed JCL job that was submitted by the administrative task scheduler.

This column contains NULL if the task is a stored procedure, if the STATUS column does not contain COMPLETED, or if the JCL job is run with JES3 in a z/OS 1.7 or earlier system.

USER_ABENDCD INTEGER Contains the user abend code returned by a failed JCL job that was submitted by the administrative task scheduler.

This column contains NULL if the task is a stored procedure, if the STATUS column does not contain COMPLETED, or if the JCL job is run with JES3 in a z/OS 1.7 or earlier system.

MSG VARCHAR(128) Contains the error or warning message from the last time the task was run.
SQLCODE INTEGER Contains the SQLCODE set by Db2 when a stored procedure was called by the administrative task scheduler. This column contains NULL if the task is a JCL job or if the STATUS column does not contain COMPLETED.
SQLSTATE CHAR(5) Contains the SQLSTATE set by Db2 when a stored procedure was called by the administrative task scheduler. This column contains NULL if the task is a JCL job or if the STATUS column does not contain COMPLETED.
SQLERRP VARCHAR(8) Contains the SQLERRP set by Db2 when a stored procedure was called by the administrative task scheduler. This column contains NULL if the task is a JCL job or if the STATUS column does not contain COMPLETED.
SQLERRMC VARCHAR(70) Contains the SQLERRMC set by Db2 when a stored procedure was called by the administrative task scheduler. This column contains NULL if the task is a JCL job or if the STATUS column does not contain COMPLETED.
DB2_SSID VARCHAR(4) Contains the Db2 subsystem ID that is associated with the administrative task scheduler that ran the task or should have run the task.
USERID VARCHAR(128) Contain the user ID that the task ran under.
Example 1: Retrieve status information about all of the tasks that have run in the administrative task scheduler task list:
   SELECT *
     FROM TABLE (DSNADM.ADMIN_TASK_STATUS()) AS T;