recent object
function:
CREATE OR REPLACE FUNCTION "COMPUTEDELAYDAYS" (
controlSeq in varchar2
)
return number
as
--计算延期申请天数
iDays number(10,2);
begin
SELECT NVL(SUM(DELAY_DAYS),0) into iDays FROM LZCITY_APPROVE_DELAY_REQUEST WHERE CAN_DELAY=1
AND APPROVE_STATUS=2
AND CONTROL_SEQ=controlSeq;
if(iDays=null) then
iDays:=0;
end if;
return(iDays);
end;
++++++++++++++
CREATE OR REPLACE FUNCTION "COMPUTEDEALMAN_EXP" (
strCondition in varchar2
)
return varchar2 is
users varchar2(4000);
luser varchar2(4000);
CURSOR mycursor is
select u.user_code into luser from framework f, position p, base_user u
where f.fram_seq=p.posi_seq and p.empl_id=u.user_code(+)
and p.empl_id=u.user_code(+)
and f.para_seq=strCondition
order by f.ordr_no;
begin
users:=‘‘;
luser:=‘‘;
open mycursor;
loop
FETCH mycursor INTO luser;
EXIT WHEN mycursor%NOTFOUND;
--串起来
users:=users || luser || ‘;‘;
end loop;
close mycursor;
--去掉最后的";"符号
luser:=‘‘;
select substr(users,1,LENGTH(users)-1) into luser from dual;
return luser;
end ;
+++++++++++++++
过程:
CREATE OR REPLACE PROCEDURE "ADDRIGHTWITHSUB" (v_objectid varchar2,v_ownerType integer,v_ownerVal varchar2,v_listFile integer,v_readAllFile integer,v_newOwnerFile integer,v_updateAllFile integer,v_updateOwnerFile integer,v_delOwnerFile integer,
v_delAllFile integer,v_dirManager integer,v_evaluate integer,v_subscribe integer,v_manager integer,v_forbidAll integer,v_approve integer,v_downloadFile integer) as
flag integer;
v_rightId integer;
v_rightValSeq integer;
v_rightSeq integer;
rightparaId integer;
rightTreeIndex varchar2(2000);
dirTreeIndex varchar2(2000);
temp varchar2(4000);
begin
select seq_value+1 into v_rightValSeq from DS_DB_SEQ where seq_name=‘ds_right_id‘;
update DS_DB_SEQ set seq_value =v_rightValSeq where seq_name=‘ds_right_id‘;
commit;
select RIGHTID,RIGHTTYPE,treeIndex into v_rightId,flag,dirTreeIndex from DS_DIR where OBJECTID=v_objectid;
select paraid,treeindex into rightparaId,rightTreeIndex from DS_RIGHTINFO where RIGHTID=v_rightId;
-----dubug信息
-- insert into DS_OPERATOR (FLOWID,Operatorid,OPERATORDATE,SUMMARY) values(getNextVal(‘ds_operator_Id‘),9,SYSDATE,‘objectid:‘||v_objectid||‘ ownerVal:‘||v_ownerVal||‘ flag:‘||flag );
-----------
if flag=0 then
--修改的权限属于根权限
insert into DS_RIGHT (RIGHTID,OWNERTYPE,OWNERVAL,listFile,readAllFile,newOwnerFile,updateAllFile,updateOwnerFile,delOwnerFile,delAllFile,dirManager,evaluate,subscribe,manager,forbidAll,approve,downloadfile,RIGHTSEQ)
(select "RIGHTID",v_ownerType as OWNERTYPE,v_ownerVal as OWNERVAL,v_listFile,v_readAllFile,v_newOwnerFile,v_updateAllFile,v_updateOwnerFile,v_delOwnerFile,v_delAllFile,v_dirManager,v_evaluate,v_subscribe,v_manager,v_forbidAll,v_approve,v_downloadfile,v_rightValSeq as RIGHTSEQ from
DS_RIGHTINFO where substr(treeIndex,1,length(rightTreeIndex))=rightTreeIndex);
---把权限值插入到所有子节点中
update DS_RIGHTINFO
--修改权限最后更新标志
set MODIFYID = MODIFYID+1 where rightid in (select rightId from
DS_RIGHTINFO where substr(treeIndex,1,length(rightTreeIndex))=rightTreeIndex);
else if flag=1 then
--修改的权限属于继承权限
select seq_value+1 into v_rightSeq from DS_DB_SEQ where seq_name=‘ds_rightinfo_id‘;
update DS_DB_SEQ set seq_value =v_rightSeq where seq_name=‘ds_rightinfo_id‘;
---获取新的权限id值
commit;
temp:=rightTreeIndex||v_rightSeq||‘.‘;
insert into DS_RIGHTINFO(RIGHTID,MODIFYID,PARAID,TREEINDEX) values (v_rightSeq,0,v_rightId,temp);
--添加新的权限id到原来权限节点下
update DS_RIGHTINFO set PARAID = v_rightSeq where
rightid in (select RIGHTID from DS_DIR where substr(treeIndex,1,length(dirTreeIndex))=dirTreeIndex)
and PARAID = v_rightId;
---更新直接子节点的树结构连接(不更新索引)
update DS_DIR set righttype=0 where objectid=v_objectid;
update DS_DIR set rightid = v_rightSeq where substr(TREEINDEX,1,length(dirTreeIndex)) = dirTreeIndex and
rightid=v_rightId;
---更新目录树的节点对应的权限值
update DS_RIGHTINFO set treeIndex=temp||substr(treeIndex, length(rightTreeIndex)+1) where
rightid in (select RIGHTID from DS_DIR where substr(treeIndex,1,length(dirTreeIndex))=dirTreeIndex) and rightid <> v_rightSeq;
--更新索引
insert into DS_RIGHT (RIGHTID,OWNERTYPE,OWNERVAL,listFile,readAllFile,newOwnerFile,updateAllFile,updateOwnerFile,delOwnerFile,delAllFile,dirManager,evaluate,subscribe,manager,forbidAll,RIGHTSEQ)
(select V_RIGHTSEQ,OWNERTYPE,OWNERVAL,listFile,readAllFile,newOwnerFile,updateAllFile,updateOwnerFile,delOwnerFile,delAllFile,dirManager,evaluate,subscribe,manager,forbidAll,RIGHTSEQ from DS_RIGHT where RIGHTID = v_rightId);
---对权限做保护性拷贝
insert into DS_RIGHT (RIGHTID,OWNERTYPE,OWNERVAL,listFile,readAllFile,newOwnerFile,updateAllFile,updateOwnerFile,delOwnerFile,delAllFile,dirManager,evaluate,subscribe,manager,forbidAll,approve,downloadfile,RIGHTSEQ)
(select RIGHTID,v_ownerType as v_OWNERTYPE,v_ownerVal as OWNERVAL,v_listFile,v_readAllFile,v_newOwnerFile,v_updateAllFile,v_updateOwnerFile,v_delOwnerFile,v_delAllFile,v_dirManager,v_evaluate,v_subscribe,v_manager,v_forbidAll,v_approve,v_downloadfile,v_rightValSeq as RIGHTSEQ from
DS_RIGHTINFO where substr(treeIndex,1,length(temp))=temp);
--复制权限到所有子节点
update DS_RIGHTINFO set MODIFYID = MODIFYID+1 where rightid in
(select rightId from DS_RIGHTINFO where substr(treeIndex,1,length(temp))=temp);
---更新权限修改标志
end if;
end if;
end addRightWithSub;
CREATE OR REPLACE PROCEDURE "REFILENAME" (v_objectid integer,v_newFileName varchar2,isFile integer) is
v_pathname varchar2(4000);
v_treeIndex varchar2(4000);
v_fileName varchar2(255);
v_fullPathName varchar2(4000);
oldPathLength integer;
begin
if isFile=1 then
update DS_DBFILE set FILENAME=v_newFileName where OBJECTID=v_objectid;
else
select FILENAME,TREEINDEX,FULLPATHNAME into v_fileName,v_treeIndex,v_fullPathName from DS_DIR where OBJECTID=v_objectid;
update DS_DIR set FILENAME=V_newFileName where OBJECTID=v_objectid;
oldPathLength := Length(v_fullPathName);
v_pathName := substr(v_fullPathName,0,oldPathLength-length(v_fileName)-1)||V_newFileName||‘/‘;
update DS_DIR set FULLPATHNAME = v_pathName||substr(FULLPATHNAME,oldPathLength+1) where substr(TREEINDEX,0,length(v_treeIndex)) = v_treeIndex;
end if;
end refilename;