flowable流程引擎,自定义函数清除流程相关数据(删除历史,任务,部署等)

-- 通过流程实例id,删除运行中的任务和历史相关数据
CREATE OR REPLACE FUNCTION public.f_delete_act_data_by_processid(_processid text)
 RETURNS void
 LANGUAGE plpgsql
AS $function$
begin
      delete   from  act_ru_actinst  where proc_inst_id_ =_processId; 
      delete   from  act_ru_identitylink  where proc_inst_id_ =_processId;
      delete   from  act_ru_task  where proc_inst_id_ =_processId;
      delete   from  act_ru_variable  where proc_inst_id_ =_processId;
      delete   from  act_ru_execution  where proc_inst_id_ =_processId;

      delete  from  act_hi_actinst where proc_inst_id_ =_processId  ;
      delete  from  act_hi_comment where proc_inst_id_ =_processId  ;
      delete  from  act_hi_identitylink  where proc_inst_id_ =_processId  ;
      delete  from  act_hi_procinst where proc_inst_id_ =_processId  ;
      delete  from  act_hi_taskinst where proc_inst_id_ =_processId  ;
      delete  from  act_hi_varinst  where proc_inst_id_ =_processId  ;
end;
$function$
;

-- 通过项目id,删除项目,及关联的任务,任务日志,流程等相关数据
CREATE OR REPLACE FUNCTION public.f_delete_project_all_by_id(_projectid integer)
 RETURNS integer
 LANGUAGE plpgsql
AS $function$
begin

-- 先删除流程信息,掉上面自定义函数的函数
        execute  format('select f_delete_act_data_by_processId(process_id)   from base_task_info
        where project_id ='||_projectId||'  and process_id  is not null');

-- 再删除业务信息
        execute format( 'delete from  base_task_log where project_id ='||_projectId||' ') ;
        execute format( 'delete from  base_task_info where project_id ='||_projectId||' ') ;
        execute format( 'delete from  base_project_info where id ='||_projectId||' ') ;
         return 1;
end;
$function$
;

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值