Batches cannot be deleted via Batch Manager or Batch Removal Utility
Issue
What are the Database queries to delete a batch that cannot be deleted via Batch Manager or Batch Removal Utility?
The Oracle command:
DECLARE plExternalBatchID INT := BatchID;
BEGIN
procDeleteBatch(plExternalBatchID);
DELETE FROM MarkedBatchFieldLong WHERE BatchID = plExternalBatchID;
DELETE FROM BatchFieldLong WHERE BatchID = plExternalBatchID;
DELETE FROM UserFieldLong WHERE BatchID = plExternalBatchID;
DELETE FROM PageCustomStringStorageExt WHERE BatchID = plExternalBatchID;
DELETE FROM DocumentCustomStringStorageExt WHERE BatchID = plExternalBatchID;
DELETE FROM ExtNotes WHERE BatchID = plExternalBatchID;
DELETE FROM FolderCustomStringStorageExt WHERE BatchID = plExternalBatchID;
DELETE FROM UserField WHERE BatchID = plExternalBatchID;
DELETE FROM BatchTotal WHERE BatchID = plExternalBatchID;
DELETE FROM BatchStatistics WHERE BatchID = plExternalBatchID;
DELETE FROM BatchQueue WHERE BatchID = plExternalBatchID;
DELETE FROM BatchCustomProperty WHERE BatchID = plExternalBatchID;
DELETE FROM FolderCustomStringStorage WHERE BatchID = plExternalBatchID;
DELETE FROM PageCustomStringStorage WHERE BatchID = plExternalBatchID;
DELETE FROM BatchPage WHERE BatchID = plExternalBatchID;
DELETE FROM BatchTable WHERE BatchID = plExternalBatchID;
DELETE FROM BatchField WHERE BatchID = plExternalBatchID;
DELETE FROM BatchDocumentProperty WHERE BatchID = plExternalBatchID;
DELETE FROM BatchDocumentPartialRel WHERE BatchID = plExternalBatchID;
DELETE FROM DocumentCustomStringStorage WHERE BatchID = plExternalBatchID;
DELETE FROM BatchDocument WHERE BatchID = plExternalBatchID;
DELETE FROM BatchFolder WHERE BatchID = plExternalBatchID;
DELETE FROM Batch WHERE BatchID = plExternalBatchID;
END;
The SQL command:
DECLARE @lExternalBatchID INT;
BEGIN
SET @lExternalBatchID = BatchID
BEGIN TRAN
EXEC procDeleteBatch @lExternalBatchID = @lExternalBatchID;
DELETE FROM MarkedBatchFieldLong WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchFieldLong WHERE BatchID = @lExternalBatchID;
DELETE FROM UserFieldLong WHERE BatchID = @lExternalBatchID;
DELETE FROM PageCustomStringStorageExt WHERE BatchID = @lExternalBatchID;
DELETE FROM DocumentCustomStringStorageExt WHERE BatchID = @lExternalBatchID;
DELETE FROM ExtNotes WHERE BatchID = @lExternalBatchID;
DELETE FROM FolderCustomStringStorageExt WHERE BatchID = @lExternalBatchID;
DELETE FROM UserField WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchTotal WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchStatistics WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchQueue WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchCustomProperty WHERE BatchID = @lExternalBatchID;
DELETE FROM FolderCustomStringStorage WHERE BatchID = @lExternalBatchID;
DELETE FROM PageCustomStringStorage WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchPage WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchTable WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchField WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchDocumentProperty WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchDocumentPartialRel WHERE BatchID = @lExternalBatchID;
DELETE FROM DocumentCustomStringStorage WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchDocument WHERE BatchID = @lExternalBatchID;
DELETE FROM BatchFolder WHERE BatchID = @lExternalBatchID;
DELETE FROM Batch WHERE BatchID = @lExternalBatchID;
COMMIT;
END;