public static void deleteRecurringBatchJob(ClassName _className, str _errorMessage)
{
Batch batch;
BatchHistory batchHistory;
BatchJob batchJob;
BatchJobHistory batchJobHistory;
select firstonly forupdate from batchJob
join forupdate from batch
where batchJob.RecId == batch.BatchJobId
&& batch.ClassNumber == className2Id(_className);
if (batch.statusClass().canDelete()
&& batchJob.Status != BatchStatus::Executing
&& batchJob.Status != BatchStatus::Scheduled
&& batchJob.Status != BatchStatus::Cancelling)
{
ttsbegin;
delete_from batchHistory
where batchHistory.BatchJobId == batchJob.RecId;
delete_from batchJobHistory
where batchJobHistory.BatchJobId == batchJob.RecId;
batch.delete();
batchJob.delete();
ttscommit;
}
else
{
throw error(_errorMessage);
}
}
No comments:
Post a Comment