How the administrative task scheduler executes a stored procedure
You can use the administrative task scheduler to execute stored procedures at a specific time. You must first define a task for the stored procedure execution. Then, when the specified time or event occurs for the stored procedure to run, the administrative task scheduler calls the stored procedure.
Specifically, the administrative task scheduler performs the following actions:
- The administrative task scheduler connects to the Db2 member that is specified in the task parameter DB2SSID. If the administrative task scheduler cannot establish a connection, it skips execution of the stored procedure and sets the last execution status to the NOTRUN state.
- The administrative task scheduler retrieves parameter values for
the stored procedure from Db2 by
using the SELECT statement that is defined in the task parameter procedure-input.
If an error occurs when the administrative task scheduler retrieves
those parameter values, the administrative task scheduler:
- Does not call the stored procedure.
- Sets the last execution status of the task to the error code that is returned by Db2.
- The administrative task scheduler issues an SQL CALL statement with the retrieved parameter values and a stored procedure name. The procedure name is concatenated from the task parameters procedure-schema and procedure-name. The SQL CALL statement is synchronous, and the execution thread is blocked until the stored procedure finishes execution. The administrative task scheduler sets the last execution status to the values that are returned by Db2.
- The administrative task scheduler issues a COMMIT statement.
- The administrative task scheduler closes the connection to Db2.