DB2 Version 9.7 for Linux, UNIX, and Windows

ADMIN_TASK_STATUS administrative view - Retrieve task status information

The ADMIN_TASK_STATUS administrative view retrieves information about the status of task execution in the administrative task scheduler.

The schema is SYSTOOLS.

This view is created the first time the ADMIN_TASK_ADD procedure is called.

Authorization

SELECT or CONTROL privilege on the ADMIN_TASK_STATUS administrative view. Unless the database was created with the RESTRICTIVE option, SELECT privilege is granted to PUBLIC by default.

When you query the ADMIN_TASK_STATUS view, it will only return the task status records that were created by your session authorization ID.

Example

Example 1: Request the status of tasks in the scheduler:
SELECT * from SYSTOOLS.ADMIN_TASK_STATUS
Example 2: Format the data in the SQLERRMC column using the SQLERRM function:
SELECT TASKID, STATUS, SQLCODE, SQLSTATE, RC,
   VARCHAR( SQLERRM( 'SQL' || CHAR( ABS(SQLCODE) ),
   SQLERRMC, x'FF', 'en_US', 1 ), 256) AS MSG_TXT
   FROM SYSTOOLS.ADMIN_TASK_STATUS

Information returned

Table 1. Information returned by the ADMIN_TASK_STATUS administrative view
Column name Data type Description
NAME VARCHAR(128) The name of the task.
TASKID INTEGER The task identifier.
STATUS VARCHAR(10) The status of the task. Valid values are:
  • RUNNING - The task is currently running.
  • COMPLETED - The task has finished running.
  • NOTRUN - An error prevented the scheduler from calling the task's procedure.
  • UNKNOWN - The task started running but an unexpected condition prevented the scheduler from recording the task outcome. This can occur if the system ends abnormally or a power failure happens while the task is running.
INVOCATION INTEGER The current invocation count.
BEGIN_TIME TIMESTAMP The time that the task began.1

If the STATUS is RUNNING, COMPLETED, or UNKNOWN, this value indicates the time that the task started running.

If the STATUS is NOTRUN, it indicates the time that the task should have started.

END_TIME TIMESTAMP The time that the task finished running.1

This value will be NULL if the STATUS is RUNNING.

If the STATUS is UNKNOWN, this value is the time the task scheduler detected the task was no longer executing and updated the status table.

AGENT_ID BIGINT agent_id - Application handle (agent ID) monitor element
SQLCODE INTEGER

If the STATUS is COMPLETED, this value indicates the SQLCODE returned by the CALL to the procedure.

If the STATUS is NOTRUN, this value indicates the SQLCODE of the error that prevented the task from running.

If the status is RUNNING or UNKNOWN, this value will be NULL.

SQLSTATE CHAR(5)

If the STATUS is COMPLETED, this value indicates the SQLSTATE returned by the CALL to the procedure.

If the STATUS is NOTRUN, this value indicates the SQLSTATE of the error that prevented the task from running.

If the status is RUNNING or UNKNOWN, this value will be NULL.

SQLERRMC VARCHAR(70) FOR BIT DATA

Contains one or more tokens, separated by X'FF', as they appear in the SQLERRMC field of the SQLCA. These tokens are substituted for variables in the descriptions of error conditions

If the STATUS is COMPLETED, this value indicates the SQLERRMC returned by the CALL to the procedure.

If the STATUS is NOTRUN, this value indicates the SQLERRMC of the error that prevented the task from running.

If the status is RUNNING or UNKNOWN, this value will be NULL.

RC INTEGER If the STATUS is COMPLETED, this contains the return code from the CALL to the procedure if the procedure had a return code. Otherwise, this will be NULL.