转:http://www.cnblogs.com/dannyli/archive/2012/11/29/2794772.html

/************************************************************************************************

**  功能:根据实例ID,删除[K2Server]中的流程实例数据(物理删除,不可恢复,操作前请备份)

**  作者:Danny,Li [xing.dong.li@163.com]

**  日期:2012-11-28

**  版本:v121128

************************************************************************************************

**  返回值        返回值描述

**  ------        --------------------------------------------------------------

**   

**

************************************************************************************************

**  修订日期        修订作者        修订描述

**  ----------    --------    -----------------------------------------------

**   

**   

************************************************************************************************/

USE [K2Server]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE [dbo].[uSP_DeleteK2ServerProcInst]

    @procInstID INT        -- Process Instance ID

AS

SET NOCOUNT ON

BEGIN

    PRINT 'Delete process instance from K2Server for ID = '+ CAST(@procInstID AS VARCHAR(50)) +' starting'

   

    DECLARE @iError INT

    SELECT @iError = @@Error

   

    BEGIN TRANSACTION

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ProcInst'

        DELETE _ProcInst WHERE ID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ProcInst'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _Async'

        DELETE _Async WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _Async'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _Code'

        DELETE _Code FROM (_Code INNER JOIN _ErrorLog E ON _Code.ID = E.CodeID ) WHERE E.ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _Code'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ErrorLog'

        DELETE _ErrorLog WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ErrorLog'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ProcInstDestQueue'

        DELETE _ProcInstDestQueue WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ProcInstDestQueue'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _FieldOnDemand'

        DELETE _FieldOnDemand WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _FieldOnDemand'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPCAsync'

        DELETE _IPCAsync FROM (_IPCAsync ia    JOIN _IPC i ON ia.ItemID = i.ID)        WHERE SrcProcInstID = @procInstID AND ia.[Type] IN (1, 3, 4)


        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPCAsync'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPCAsync'

        DELETE _IPCAsync FROM (_IPCAsync ia JOIN _IPCReturn i ON ia.ItemID = i.DstProcInstID)        WHERE DstProcInstID = @procInstID AND ia.[Type] IN (2)

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPCAsync'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPC'

        DELETE _IPC WHERE SrcProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPC'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPC'

        DELETE _IPC WHERE DstProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPC'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPCReturn'

        DELETE _IPCReturn WHERE SrcProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPCReturn'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _IPCReturn'

        DELETE _IPCReturn WHERE DstProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _IPCReturn'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _Log'

        DELETE _Log WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _Log'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ServerList'

        DELETE _ServerList WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ServerList'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _WorklistHeader'

        DELETE _WorklistHeader WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _WorklistHeader'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _WorklistSlot'

        DELETE _WorklistSlot WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _WorklistSlot'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ActionActInstRights'

        DELETE _ActionActInstRights WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ActionActInstRights'

        SELECT @iError = @@ERROR

    END

   

    IF @iError = 0

    BEGIN

        PRINT 'Removing process instance from _ActionActInstShared'

        DELETE _ActionActInstShared WHERE ProcInstID = @procInstID

        PRINT CAST(@@ROWCOUNT AS VARCHAR(10)) + ' records removed from _ActionActInstShared'

        SELECT @iError = @@ERROR

    END

   

    IF @iError <> 0

    BEGIN

        ROLLBACK TRANSACTION

        PRINT 'Delete process instance from K2Server for ID = '+ CAST(@procInstID AS VARCHAR(50)) +' rollback'

    END

    ELSE

    BEGIN

        COMMIT TRANSACTION

        PRINT 'Delete process instance from K2Server for ID = '+ CAST(@procInstID AS VARCHAR(50)) +' commit'

    END

END

K2 Blackpearl中从数据库直接删除流程实例之K2Server表的更多相关文章

  1. K2 Blackpearl中从数据库直接删除流程实例之K2ServerLog表

    转:http://www.cnblogs.com/dannyli/archive/2012/11/29/2794845.html /********************************** ...

  2. EBS中OPM成本更新处理流程及对应的表结构、SLA表

    OPM成本更新流程:  1.跑实际成本处理  功能作用:计算成本  2.成本更新        功能作用:更新成本  3.OPM会计预处理程序->活动->提交流程 功能作用:是创建会计事件 ...

  3. 工作流学习——Activiti流程实例、任务管理四步曲 (zhuan)

    http://blog.csdn.net/zwk626542417/article/details/46646565 ***************************************** ...

  4. Activiti的流程实例及挂起激活(七)

    1.1什么是流程实例 参与者(可以是用户也可以是程序)按照流程定义内容发起一个流程,这就是一个流程实例.是动态的.流程定义和流程实例的图解: 1.2启动流程实例 流程定义部署在 activiti 后, ...

  5. Activiti 流程实例、任务、执行对象及相关的表

    一个流程中,流程实例只有一个,执行对象可以有多个(如果存在分支和聚合) SELECT * FROM activiti.act_ru_execution a;  #正在执行的执行对象表 SELECT * ...

  6. 将数据库中的表注册到K2服务中,并封装为Smart Object

    转:http://www.cnblogs.com/dannyli/archive/2011/08/15/2139550.html K2 blackpearl项目中经常需要将其他数据中的表注册到K2服务 ...

  7. 使用C#代码发起K2 Blackpearl流程

    转:http://www.cnblogs.com/dannyli/archive/2011/08/02/2125285.html 使用C#代码,发起一个K2的流程,其形式和链接SQL Server数据 ...

  8. K2 blackpearl 流程开发(二)

    转:http://blog.csdn.net/gxiangzi/article/details/8444590 本来想一篇文章把流程开发介绍完的,后来发现实在是太多了,只好分成两部分了.上一篇很简单的 ...

  9. K2 blackpearl 流程开发(一)

    转:http://blog.csdn.net/gxiangzi/article/details/8444060 郁闷,今天K2的license过期了,很多东西都没法用了,还得去找PM大大帮忙申请一个. ...

随机推荐

  1. 【剑指offer】找出数组中任意一个重复的数字,C++实现

    原创博文,转载请注明出处! # 题目 # 思路 对于长度为n的数组,范围为0~n-1的数字而言,如果不粗在重复数字,则排序后数组元素和数组角标相同.如果存在重复数字,则在排序的过程中会出现不同下标对应 ...

  2. ios 延迟调用 && UIImageView && UILabel && UISegmentedControl && UISwitch && UISlider

    // //  ViewController.m //  UI_Lesson3 // //  Created by archerzz on 15/8/13. //  Copyright (c) 2015 ...

  3. 给StackPanel的子元素添加padding

    <StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type TextBox}"> ...

  4. 怎样创建Linux Initrd

    Linux初始RAM磁盘(initrd)是在系统引导过程中挂载的一个暂时根文件系统,用来支持两阶段的引导过程.initrd文件里包括了各种可运行程序和驱动程序.它们能够用来挂载实际的根文件系统,然后再 ...

  5. eclipse marketplace网络连接失败的解决方法

    2015-12-04 01:12:33 本想在eclipse上安装一个插件,点进help-EclipseMarketplace却连接失败,错误如下: 在help-instal new software ...

  6. Wordpress主题站

    深度剖析WordPress主题结构 http://down.chinaz.com/try/201106/640_1.htm wordpress工作原理 http://blog.csdn.net/liu ...

  7. Oracle修改主键约束

    项目需求,有张表,原有三个联合主键,现在需要再加一个字段进去,而恰恰这个字段可以为空的.去数据库捞了一把,还好数据都不为空: SQL> select count(*) from t_wlf_re ...

  8. java 简洁的分层实现

    1.分页实现 分页实现是将所有查询结果保存在session对象或集合中,翻页时从session对象或集合中取出一页所需的数据显示.但是这种方法有两个最主要的缺点:一是用户看到的可能是过期数据:二是如果 ...

  9. Python Socke

    回射 SERVER #!/usr/bin/python3 #_*_ coding:utf- _*_ import socket,os,time import socketserver import t ...

  10. C++中如何在顺序容器中删除符合特定条件的元素

    以前很少做删除操作,vector一直当成数组用,而实际追求效率时又经常舍弃vector选用C风格数组.看<C++ Primer>到顺序容器删除这节时试着实现课后习题结果一动手我就出错了. ...