事例1:
create or replace procedure sp_addProjectQj(
ret out number,
flowid in number --流程Id
)
as
cursor c_design is
select * from LC_VR_Detail where lc_crm_visitreport_Id = flowid and dd_status != 2;
c_row c_design%rowtype;
v_id number;
begin
for c_row in c_design loop
pnextid('T_XMSJQJ',v_id);
--项目涉及器件(id,项目名称,器件) values --design明细表(v_id,项目名称,器件名称)
insert into T_XMSJQJ(id,f2,sj,fqj,f3,cj,fsl,fbz,fqzje,fldknx,fldjz,fcyyy,fdocnum,fgdyy,f6,bz)
values (v_id,c_row.dd_project,c_row.DD_Newtime,c_row.dd_name,c_row.dd_model,c_row.dd_brand,
c_row.dd_num,c_row.dd_currency,c_row.dd_HideCash,c_row.DD_SureChance,c_row.DD_SureEvolve,
c_row.DD_Difference,c_row.dd_docnum,c_row.dd_whyclose,c_row.dd_Designinstatus,c_row.dd_remarks );
commit;
end loop;
ret:=1;
EXCEPTION
WHEN OTHERS THEN
ret:=-1;
end;
事例2:
CREATE OR REPLACE PROCEDURE sp_empAttendSetAdd (
o_Ret out int,
o_RetInfo out varchar2,
i_type in int, --类别:1|部门;2|员工;3|角色
i_company int,--公司
i_deptEmpRole in varchar2, --部门或员工或角色
i_validDate date,--生效日期
i_invalidDate date,--失效日期
i_user int, --登录用户
i_attendTeam int --考勤班组
)
is
v_nextid number;
v_worktype number;
v_invalidDate date;
v_sql varchar2(5000);
v_strSql varchar2(5000);
cur_data types.cursorType;
v_employeeId number;
v_deptId number;
v_flag1 number;
v_flag2 number;
begin
v_invalidDate:=i_invalidDate;
--失效日期为空时,取当前年份的年底时间
if i_invalidDate is null then
--select add_months(trunc(i_validDate, 'yyyy'), 12)-1 into v_invalidDate from dual;
select max(a.fenddate) into v_invalidDate from HRM_AttendPeriod a where a.fcompany = i_company;
end if;
--判断生效时间至失效时间是否有未开账的考核期间
select count(1) into v_flag1 from Hrm_Attendperiod a where a.fbegindate<=i_validDate and i_validDate<=a.fenddate and a.fcompany = i_company;
select count(1) into v_flag2 from Hrm_Attendperiod a where a.fbegindate<=nvl(i_invalidDate,v_invalidDate) and nvl(i_invalidDate,v_invalidDate)<=a.fenddate and a.fcompany = i_company;
if v_flag1=0 or v_flag2=0 then
o_Ret:=-1;
o_RetInfo:='该生效时间段存在考勤期间未开账!';
return;
end if;
--查找工作种类
select fworktype into v_worktype from HRM_AttendTeam where id = i_attendTeam;
--类别是部门
if i_type=1 then
v_sql:=' instr('';''||'''||i_deptEmpRole||'''||'';'','';''||a.fdept||'';'')>0';
--类别是员工
elsif i_type=2 then
v_sql:=' instr('';''||'''||i_deptEmpRole||'''||'';'','';''||a.id||'';'')>0';
--类别是角色
elsif i_type=3 then
v_sql:=' a.id in ( select femployee from tuser where id in (select distinct userid from lbmember where
instr('';''||'''||i_deptEmpRole||'''||'';'','';''||roleid||'';'')>0
and orgid in (select id from lbOrganization where fun_findComOrgId(ID)='''||i_company||''')))';
end if;
v_strSql:= 'select a.id,a.fdept from PUB_Employee a where '||v_sql;
--dbms_output.put_line(v_strSql);
open cur_data for v_strSql;
loop
fetch cur_data into v_employeeId,v_deptId;
exit when cur_data%notfound;
--生效时间段交叉检查
sp_HRM_EmpAttendSet(o_Ret,o_RetInfo,i_company,v_employeeId,i_validDate,i_invalidDate);
if o_Ret<0 then
return;
end if;
pnextid('HRM_EmpAttendSet',v_nextid);
--新增员工考勤设置
insert into HRM_EmpAttendSet(id,Fcompany,Fdept,Femployee,Fattendteam,Fcard,Fvaliddate,Finvaliddate,Fuser,Ftime)
values(v_nextid,i_company,v_deptId,v_employeeId,i_attendTeam,1,i_validDate,i_invalidDate,i_user,sysdate);
commit;
for cs_attendPeriod in (
--查询考勤期间
select a.id from HRM_AttendPeriod a where a.fbegindate between i_validDate and nvl(i_invalidDate,v_invalidDate)
)
loop
sp_HRM_WorkDuty(o_Ret,o_RetInfo,1,'批量新增员工考勤设置自动完成排班',i_user,cs_attendPeriod.id,v_worktype,v_employeeId);
--add By kaixian.zheng
sp_HRM_WorkDuty_Temp(o_Ret,o_RetInfo,1,'批量新增员工考勤设置自动完成排班',i_user,cs_attendPeriod.id,v_worktype,v_employeeId);
if o_Ret<0 then
return;
end if;
commit;
end loop;
commit;
end loop;
close cur_data;
end sp_empAttendSetAdd;