diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 3dd65899..76512bb3 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -8882,6 +8882,7 @@ BEGIN TRY -- Try Block DECLARE @PreviousItemID AS INT DECLARE @ExternalChildCount AS INT DECLARE @ExternalCount AS INT + DECLARE @ItemType AS INT DECLARE @Path AS VARCHAR(MAX) DECLARE @Children AS TABLE ( @@ -8899,17 +8900,25 @@ BEGIN TRY -- Try Block ) SET NOCOUNT ON SELECT @ContentID = ContentID, @PreviousItemID = PreviousID FROM Items WHERE ItemID = @ItemID - SELECT @NextItemID = ItemID FROM Items ii join Contents cc on cc.contentid = ii.contentid WHERE PreviousID = @ItemID and cc.type > 0 + SELECT @NextItemID = ItemID FROM Items WHERE PreviousID = @ItemID + SELECT @ExternalCount = count(*) FROM vefn_FindExternalTransitions(@ItemID) where rangeid = toid or toid = @ItemID SELECT @ExternalChildCount = count(*) FROM vefn_FindExternalChildTransitions(@ItemID) + SELECT @ItemType = Type FROM Contents Where ContentID = @ContentID SET @Path = [dbo].[ve_GetShortPath](@ItemID) - + -- Check to see if External Transitions point to the current item IF @ExternalCount > 0 AND @NextItemID is null BEGIN RAISERROR ('###Cannot Delete Item###Step %d has External Transitions and has no next step - (%s)',16,1,@ItemID,@Path) RETURN END + IF @ExternalCount > 0 AND @ItemType < 10000 + BEGIN + RAISERROR ('###Cannot Delete Item###Procedure %d has External Transitions to Procedure - (%s)',16,1,@ItemID,@Path) + RETURN + END + IF @ExternalChildCount > 0 BEGIN RAISERROR ('###Cannot Delete Item###Step %d has External Transitions to it''s children - (%s)',16,1,@ItemID,@Path)