CancelJobs
Cancels one or more Vault jobs that are queued or scheduled to run.
Stored Procedure-Specific Information
Rather than passing a list of Ids, the JobList input takes the name of a temporary (#TEMP) table that holds the job Ids to cancel, one per row. Only a job in a QUEUED or QUEUEING state can be cancelled.Job Ids are submitted in batches (up to 500 per request); larger tables are split into multiple requests automatically. The operation returns one row per job, indicating whether it was cancelled and, for any job that could not be cancelled, the error details.
Populating the JobList Temporary Table
A temporary table is a connection-scoped table whose name ends in #TEMP. You do not create it explicitly: the first INSERT INTO that uses the #TEMP name brings the table into existence, and each subsequent INSERT adds more rows. Temporary tables last only as long as the current connection is open and are discarded when the connection is closed.
The recommended way to populate the table is an INSERT INTO SELECT query that reads the Ids directly from the JobMonitors view, which lists the jobs that are scheduled, queued, or running in the authenticated Vault. An INSERT INTO SELECT selects a group of records from one table and inserts them into another as a single batch, which performs better than issuing many individual INSERT statements:
INSERT INTO JobList#TEMP (JobId) SELECT JobId FROM JobMonitors WHERE Status = 'QUEUED'
The column list in parentheses maps each selected value into the temporary table: here the JobId column of the JobMonitors view is written into the JobId column of JobList#TEMP. Adjust the WHERE clause to control exactly which jobs are cancelled. You can also add rows one at a time with INSERT INTO ... VALUES:
INSERT INTO JobList#TEMP (JobId) VALUES ('1046892')
INSERT INTO JobList#TEMP (JobId) VALUES ('1043341')
Once the temporary table is populated, pass its name to the procedure through the JobList input:
EXEC CancelJobs JobList = 'JobList#TEMP'
JobList Temporary Table Schema
| Column Name | Type | Required | Description |
| JobId | String | True | The Id of a job to cancel. Populate it from the JobId column of the JobMonitors view. |
Input
| Name | Type | Required | Description |
| JobList | String | True | The list of jobs to cancel. The value can be a comma-separated list of job Ids (for example, '123,456,789') or a temporary table (#TEMP) containing a 'JobId' column. Job Ids are submitted in batches of up to 500; larger lists are split into multiple requests automatically. Only a job in a QUEUED or QUEUEING state can be cancelled. |
Result Set Columns
| Name | Type | Description |
| JobId | String | The Id of the job that was cancelled. Populated for jobs that were cancelled successfully. |
| Success | String | Indicates whether the job was cancelled successfully. |
| ErrorType | String | The type of error returned for a job that could not be cancelled (for example, INVALID_DATA). Empty when the job was cancelled successfully. |
| ErrorMessage | String | The error message returned for a job that could not be cancelled (for example, when the job is not in a QUEUED or QUEUEING state). Empty when the job was cancelled successfully. |