上次传了一个游标的缴费 这个再上传个游标的导入 这个是用fetch游标做的
create or replace procedure l_f_daoru_lab_expert ( resultStr out varchar, v_userid in CHAR ) is v_str varchar(500); m number; n number; k number; v_mac l_apply_log.mac%type; v_ip l_apply_log.ip%type; v_tele l_apply_log.tele%type; v_mobilephone l_apply_log.mobilephone%type; v_cnt number; v_expert_no l_lab_expert_temp.expert_no%type; v_expert_desc l_lab_expert_temp.expert_desc%type; cursor c_expert is select expert_no,expert_desc from l_lab_expert_temp where user_id=v_userid ORDER by expert_no asc ; --****************************************************钟冬冬******************************************** Begin --请自行编辑存储过程函数体 select count(distinct(expert_no)) into m from l_lab_expert_temp where user_id=v_userid; select count(expert_no) into n from l_lab_expert_temp where user_id=v_userid; if n>m then ResultStr := ‘error: 有重复的专家号,请核对.‘; return; end if; open c_expert; fetch c_expert into v_expert_no,v_expert_desc; while c_expert%found loop select count(*) into v_cnt from l_lab_expert where expert_no=v_expert_no; if v_cnt>0 then v_str:=trim(v_str||‘专家编号为‘||v_expert_no||‘已存在<br />‘); end if; fetch c_expert into v_expert_no,v_expert_desc; end loop; close c_expert; if trim(v_str) is not null or trim(v_str) <>‘‘ then ResultStr:=trim(v_str)||‘请核对!<br />‘; return; end if; --导入数据 insert into l_lab_expert(expert_no,expert_desc) select expert_no,expert_desc from l_lab_expert_temp where user_id=v_userid ; delete l_lab_expert_temp; --插入日志 select distinct(mac) into v_mac from l_lab_mac_temp where trim(member_no)=trim(v_userid); select distinct(ip) into v_ip from l_lab_mac_temp where trim(member_no)=trim(v_userid); select nvl(tele,‘无‘) into v_tele from emp_def where trim(emp_no)=trim(v_userid); select nvl(mobilephone,‘无‘) into v_mobilephone from emp_def where trim(emp_no)=trim(v_userid); insert into l_apply_log(id,op_man,tele,mobilephone,message,op_date,mac,ip) values(l_log.nextval,v_userid,v_tele,v_mobilephone,‘导入了专家类别信息‘,sysdate,v_mac,v_ip); --删除临时表 delete from l_lab_mac_temp where trim(member_no)=trim(v_userid); ResultStr := ‘success: 导入成功.‘; End;
时间: 2024-10-08 14:23:19