Changeset 17586 for branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts
- Timestamp:
- 06/04/20 15:55:13 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
/trunk merged: 17574-17576,17579-17581,17583-17585
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Services.Hive.DataAccess merged: 17574
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql
r16723 r17586 141 141 INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId]) 142 142 GO 143 144 145 146 -- OBSOLETE - DO NOT PERFORM (start)147 /****** Object: Trigger [dbo].[tr_JobDeleteCascade] Script Date: 04/19/2011 16:31:53 ******/148 SET ANSI_NULLS ON149 GO150 SET QUOTED_IDENTIFIER ON151 GO152 -- =============================================153 -- Author: cneumuel154 -- Create date: 19.04.2011155 -- Description: (1) Writes the execution times of deleted jobs into DeletedJobStats to ensure correct statistics156 -- (2) Deletes all associated jobs. This cannot be done with cascading delete,157 -- because the job table defines a INSTEAD OF DELETE trigger itself, which158 -- is not compatible with cascading deletes.159 -- =============================================160 CREATE TRIGGER [dbo].[tr_JobDeleteCascade] ON [dbo].[Job] INSTEAD OF DELETE AS161 BEGIN162 DELETE Task FROM deleted, Task WHERE deleted.JobId = Task.JobId163 DELETE Job FROM deleted, Job WHERE deleted.JobId = Job.JobId164 END165 GO166 167 -- =============================================168 -- Author: cneumuel169 -- Create date: 11.11.2010170 -- Description: Recursively deletes all child-jobs of a job when it is deleted. (Source: http://devio.wordpress.com/2008/05/23/recursive-delete-in-sql-server/)171 -- =============================================DeletedJobStatistics172 CREATE TRIGGER [dbo].[tr_TaskDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS173 BEGIN174 -- recursively delete jobs175 CREATE TABLE #Table(176 TaskId uniqueidentifier177 )178 INSERT INTO #Table (TaskId)179 SELECT TaskId FROM deleted180 181 DECLARE @c INT182 SET @c = 0183 184 WHILE @c <> (SELECT COUNT(TaskId) FROM #Table) BEGIN185 SELECT @c = COUNT(TaskId) FROM #Table186 187 INSERT INTO #Table (TaskId)188 SELECT Task.TaskId189 FROM Task190 LEFT OUTER JOIN #Table ON Task.TaskId = #Table.TaskId191 WHERE Task.ParentTaskId IN (SELECT TaskId FROM #Table)192 AND #Table.TaskId IS NULL193 END194 195 DELETE TaskData FROM TaskData INNER JOIN #Table ON TaskData.TaskId = #Table.TaskId196 DELETE Task FROM Task INNER JOIN #Table ON Task.TaskId = #Table.TaskId197 END198 GO199 -- OBSOLETE (end)200
Note: See TracChangeset
for help on using the changeset viewer.