create or replace
procedure prod_fixing_datacb IS
type cur_userId is ref cursor; -- 游动浮标定义
c_msgUserIds cur_userId;
c_actionUserIds cur_userId;
c_msgUids cur_userId;
c_todoUserIds cur_userId;
mysql varchar2(4000);
n_msgUserId number:=0; -- 承办用户wf_msg.nUserId
n_actionUserId number:=0; -- 承办用户wf_proc_action.nUserId
n_msgUid number:=0; -- 来文登记用户wf_msg.nUserId
v_todoUserIds varchar2(2000);
n_userId number:=0; -- 获取的承办用户结果
n_nDocId number:=0;
n_nFlowId number:=0;
CURSOR c_fixing_docIds IS
-- 修复收文中批示,拟办节点缺少续办对象的数据
select
gwe.nDocId, gwe.nFlowId
from
wf_doc_gw gw, wf_doc_gw_entity gwe
where gw.ndocId = gwe.ndocId
and gw.ndocsortId = 1
and gw.nstate=0
and gw.cProcUserList is null
and gw.nProcId in (66,10)
order by gw.nDocId;
begin
open c_fixing_docIds;
Loop
Fetch c_fixing_docIds into
n_nDocId,n_nFlowId;
if (n_nFlowId>0) then
-- 获得承办用户USERID
mysql := 'select msgUserId from ('||
'select nMsgId, nUserId as msgUserId,currentProcId,'||
'row_number() over(partition by currentProcId order by dwrite desc) rowNumberId '||
'from wf_msg '||
'where currentProcId = 64 and ndocid='||n_nDocId||') a where rowNumberId=1';
open c_msgUserIds for mysql;
loop
fetch c_msgUserIds into n_msgUserId;
exit when c_msgUserIds%notfound;
if(n_msgUserId>0) then
n_userId := n_msgUserId;
end if;
end loop;
close c_msgUserIds;
if (n_userId=0) then
mysql := 'select actionUserId from '||
'(select nUserId as actionUserId, '||
'row_number() over(partition by nFlowId order by dRecvDate desc) rowNumberId '||
'from wf_proc_action '||
'where nProcId = 64 and '||
'ndocid='||n_nDocId||') a where rowNumberId=1";';
open c_actionUserIds for mysql;
loop
fetch c_actionUserIds into n_actionUserId;
exit when c_actionUserIds%notfound;
if(n_actionUserId>0) then
n_userId := n_actionUserId;
end if;
end loop;
close c_actionUserIds;
end if;
if (n_userId=0) then
mysql := 'select msgUserId from ('||
'select nMsgId, nUserId as msgUserId,currentProcId,'||
'row_number() over(partition by currentProcId order by dwrite desc) rowNumberId '||
'from wf_msg '||
'where currentProcId = 20 and ndocid='||n_nDocId||') a where rowNumberId=1';
open c_msgUids for mysql;
loop
fetch c_msgUids into n_msgUid;
exit when c_msgUids%notfound;
if(n_msgUid>0) then
n_userId := n_msgUid;
end if;
end loop;
close c_msgUids;
end if;
Dbms_Output.put_line('n_userId:'||n_userId);
mysql:='update dispatch_entitylog '||
'set sendstatus=1, receiveuserid='||n_userId||','||
'receivedate=sysdate,receivestatus=1,'||
'receiveusername=(select u.realname from tbuser u where u.userid='||n_userId||'),'||
'receiveentityname=(select e1.entityname from tbuser u, tbentity e1 where u.currententityid=e1.entityid and u.userid='||n_userId||'),'||
'receiveorgname=(select e2.entityname from tbuser u, tbentity e1, tbentity e2 where u.currententityid=e1.entityid and e1.belongedentityid = e2.entityid and u.userid = '||n_userId||') '||
'where nFlowId='||n_nFlowId||' and receivedate is null and nProcId = 64'; -- 承办部门修改,其它暂时不修改
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql:='insert into wf_proc_flow (nFlowId,nDocId, nProcId, nDocsortId, '||
'dRecvDate,dFnshDate, nFinishStatus,nOrder, nAndOr)'||
'select '||n_nFlowId||', '||n_nDocId||', 64, 1, sysdate,sysdate,1, 0,0 from dual where not exists '||
'(select nFlowId from wf_proc_flow where nDocId='||n_nDocId||' '||
'and nProcId=64 and nFlowId='||n_nFlowId||')';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql := 'update wf_proc_flow set cUserList='||to_char(n_userId)||' '||
'where nFlowId = '||n_nFlowId||' and nDocId='||n_nDocId||' '||
'and cUserList is null';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql := 'update wf_proc_flow set dFnshDate=sysdate, nFinishStatus=1 '||
'where nFlowId ='||n_nFlowId||' and nDocId='||n_nDocId||' '||
'and dFnshDate is null';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql := 'insert into wf_proc_action (nDocId, nUserId, nDocsortId, nProcId,dRecvDate,dFnshDate, nFinishStatus,nOrder, nAndOr, nFlowId) '||
'select '||n_nDocId||','||n_userId||',1,64,sysdate,sysdate,1,0,0,'||n_nFlowId||' '||
'from dual where not exists '||
'(select nFlowId from wf_proc_action where nDocId='||n_nDocId||' and nProcId=64 and nFlowId='||n_nFlowId||')';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql:= 'update wf_proc_action set nUserId='||n_userId||' '||
'where nFlowId ='||n_nFlowId||' and nDocId='||n_nDocId||' and nUserId is null';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql := 'update wf_proc_action set dFnshDate=sysdate, nFinishStatus=1 '||
'where nFlowId = '||n_nFlowId||' and nDocId='||n_nDocId||' and dFnshDate is null';
execute immediate mysql;
Dbms_Output.put_line(mysql);
mysql := 'delete from wf_doc_gw_entity where nFlowid='||n_nFlowId;
execute immediate mySql;
Dbms_Output.put_line(mysql);
mysql := 'select wmsys.wm_concat(d.nUserId) from (select wpa.nFlowId, wpa.nUserId,'||
'row_number() over (partition by wpa.nDocId order by wpa.nFlowId) rowNumId,'||
'row_number() over (partition by wpa.nFlowId order by wpa.nOrder desc) rowNumberId '||
'from wf_proc_action wpa, wf_doc_gw gw '||
'where wpa.ndocid = gw.nDocId '||
'and wpa.nProcId = gw.nProcId '||
'and wpa.dfnshdate is null '||
'and gw.nDocId = '||n_nDocId||') d where d.rowNumberId=1 and d.rowNumId=1';
Dbms_Output.put_line(mysql);
open c_todoUserIds for mysql;
loop
fetch c_todoUserIds into v_todoUserIds;
exit when c_todoUserIds%notfound;
Dbms_Output.put_line('v_todoUserIds:'||v_todoUserIds);
end loop;
close c_todoUserIds;
if(v_todoUserIds is null) then
mysql:='update wf_doc_gw set cProcUserList='||n_userId||', nProcStatus=1 where nDocId='||n_nDocId;
else
mysql:='update wf_doc_gw set cProcUserList='||v_todoUserIds||',nProcStatus=0 where nDocId='||n_nDocId;
end if;
execute immediate mySql;
Dbms_Output.put_line(mysql);
end if;
Exit when c_fixing_docIds%notfound;
end loop;
commit;
Exception
when others then
close c_fixing_docIds;
rollback;
Dbms_Output.put_line(Sqlerrm);
if c_fixing_docIds%isopen then
close c_fixing_docIds;
end if;
end prod_fixing_datacb;
分享到:
相关推荐
在 Oracle9i 之前,不可能从 Java 存储过程直接返回一个 ResultSet,因为没有定义表单 ResultSet->REF CURSOR 的映射。Oracle9i 增加了此映射,允许从函数返回 ResultSet 或将其作为 OUT 参数传到某个过程。但它仍不...
在数据开发中,有时你需要合并两个动态游标sys_refcursor。 开发一个存储过程PROC_A,这个过程业务逻辑相当复杂,代码篇幅较长。一段时间后要开发一个PROC_B,要用PROC_A同样的逻辑,而且在这个过程中,还要循环调用...
关于一个Ref和Out参数的例子,更易理解Ref和Out参数
ref 是 C# 7.0 的一个语言特性,为开发人员提供了返回本地变量引用和值引用的机制。Span 则是一个建立在 ref 语法基础上的复杂的数据类型,提供了安全的访问内存区域指针的能力。 一、ref 关键字 ref 关键字是 C# ...
本手册详细介绍了馈线保护继电器REF_615的原理及操作。
全面详细的讲解REF_ET软件的使用,并对各种方法深层分析
Vue使用Ref跨层级获取组件的步骤 Vue使用Ref跨层级获取组件实例 在开发过程中,我们难免会使用到跨层级的ref实例获取,大部分情况下,我们都可以通过组件自身的parent或者children去找到需要的实例。但是当层级...
父组件通过 ref引用子组件中的属性,然后在父组件中通过ref去改变子组件的属性值
引用参数 REF的使用
很好abb综保是一个非常好的保护资料 还请大家多多交流
ABB馈线保护测控装置REF611产品指南pdf,ABB馈线保护测控装置REF611产品指南:REF611 馈线保护测控装置,专为公用和工业配电系统的保护、控制、测量和监视而设计,可用于辐射型、环型或网络型配电网络,支持带有分布式...
PLSQL中显示Cursor、隐示Cursor、动态Ref_Cursor区别(有分支图解)
ref3225使用说明,链接电路以及物理特性
一、ref的基本使用 ref的使用 <!-- `vm.$refs.p`将会是DOM结点 --> <p ref=p>hello <!-- `vm.$refs.child`将会是子组件实例 --> <child ref=child> 如果在普通的 DOM 元素上使用,引用指向的就是DOM ...
var ref = require('ref') var StructType = require('ref-struct') // define the time types var time_t = ref.types.long var suseconds_t = ref.types.long // define the "timeval" struct type var timeval ...
Span也是建立在ref语法基础上的一个复杂的数据类型,在文章的后半部分,我会有一个例子说明如何使用它。 二、ref关键字 不论是ref还是out关键,都是一种比较难以理解和操作的语言特性,如C语言中操作指针一样,这样...
out和ref的区别 out和ref的区别
Extref
ABB 保护装置 REF542 使用modbus通讯时,内部功能码、设置等资料