Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
titleMySQL
SET FOREIGN_KEY_CHECKS=0;
 
delete sa from SHKAssignmentsTable as sa
left join SHKProcesses as sp on sa.ActivityProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete sadsaj from SHKAndJoinTable as saj
left join SHKActivities as sac on saj.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sadsd from SHKDeadlines as sd
left join SHKActivities as sac on sd.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sad from SHKActivityData as sad
left join SHKActivities as sac on sad.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
delete sac from SHKActivities as sac
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete spd from SHKProcessData as spd
left join SHKProcesses as sp on spd.Process = sp.oid
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete spr from SHKProcessRequesters as spr
left join SHKProcesses as sp on spr.Id = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 

delete from SHKProcesses where (State = 1000006 or State = 1000008 or State = 1000010); 
 
SET FOREIGN_KEY_CHECKS=1;

...

Code Block
languagesql
titleOracle
delete (select sa.* from SHKAssignmentsTable sa
left join SHKProcesses sp on sa.ActivityProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010));

delete sad from SHKAndJoinTable as saj
left join SHKActivities as sac on saj.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete sad from SHKDeadlines as sd
left join SHKActivities as sac on sd.Activity = sac.oid
left join SHKProcesses as sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010); 
 
delete (select sad.* from SHKActivityData sad
left join SHKActivities sac on sad.Activity = sac.oid
left join SHKProcesses sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 
 
delete (select sac.* from SHKActivities sac
left join SHKProcesses sp on sac.ProcessId = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete (select spd.* from SHKProcessData spd
left join SHKProcesses sp on spd.Process = sp.oid
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete (select spr.* from SHKProcessRequesters spr
left join SHKProcesses sp on spr.Id = sp.ID
where (sp.State = 1000006 or sp.State = 1000008 or sp.State = 1000010)); 

delete from SHKProcesses where (State = 1000006 or State = 1000008 or State = 1000010); 

...


If you would like to clean the all the process instances data including the running process instances, you can use the following query.

...

Code Block
languagesql
titleOracle
delete (select xd.* from SHKXPDLData xd
left join SHKXPDLS x on x.oid= xd.XPDL
where concat(x.XPDLId, x.XPDLVersion) not in (
    select concat(packageId,packageVersion) as id from (
        select def.PackageId as packageId, TO_CHAR(def.ProcessDefinitionVersion) as packageVersion 
        from SHKActivities act 
        join SHKProcesses pro on act.Process = pro.oid 
        left join SHKProcessDefinitions def on pro.ProcessDefinition = def.oid 
        group by def.PackageId, def.ProcessDefinitionVersion 
        union 
        select packageId, TO_CHAR(packageVersion) from app_package
    ) group by packageId, packageVersion
));

delete (select x.* from SHKXPDLS x 
where concat(x.XPDLId, x.XPDLVersion) not in (
    select concat(packageId,packageVersion) as id from (
        select def.PackageId as packageId, TO_CHAR(def.ProcessDefinitionVersion) as packageVersion 
        from SHKActivities act 
        join SHKProcesses pro on act.Process = pro.oid 
        left join SHKProcessDefinitions def on pro.ProcessDefinition = def.oid 
        group by def.PackageId, def.ProcessDefinitionVersion 
        union 
        select packageId, TO_CHAR(packageVersion) from app_package
    ) group by packageId, packageVersion
));

 

...