oracle按rownum更新数据
2016-05-25 20:47
417 查看
create or replace procedure repair_accept_final_x_20160520 is
begin
declare
cursor c_job
is
select t.act_code from acceptance t where nvl(t.act_flag,'0')='1' and t.is_history!='1';
c_row c_job%rowtype;
v_count1 number;
v_count2 number;
v_grant_code number;
v_wf_id number;
v_status varchar2(10);
v_count3 number;
v_rn number;
begin
for c_row in c_job loop
v_count3:=2;
select t.grant_code into v_grant_code from project t where t.prj_code in(select a.prj_code from acceptance a where a.act_code=c_row.act_code);
if instr(',429,198,199,200,201,202,203,204,',','||v_grant_code||',')>0 then
v_wf_id:=120000103;
else
v_wf_id:=100000401;
end if;
select count(0) into v_count1 from audit_comment t where t.key_code=c_row.act_code and t.comment_type='acceptance_final';
select count(0) into v_count2 from wf_his_task t where t.op_code=c_row.act_code and t.wf_id=v_wf_id and t.status!='00';
if v_count1>0 and v_count1=v_count2 then
for i in 1..v_count1 loop
select rn,status into v_rn,v_status from (select rownum rn,status from wf_his_task w where w.wf_id=v_wf_id and w.status!='00' and w.op_code=c_row.act_code and rownum<v_count3 order by w.id ) where rn>=i;
update audit_comment t set t.status=v_status
where t.seq_no in(select seq_no from (select seq_no,rownum rn from audit_comment t where t.key_code=c_row.act_code and t.comment_type='acceptance_final' and rownum<v_count3 order by t.seq_no) where rn>=i);
v_count3:=v_count3+1;
end loop;
end if;
end loop;
end;
end repair_accept_final_x_20160520;
begin
declare
cursor c_job
is
select t.act_code from acceptance t where nvl(t.act_flag,'0')='1' and t.is_history!='1';
c_row c_job%rowtype;
v_count1 number;
v_count2 number;
v_grant_code number;
v_wf_id number;
v_status varchar2(10);
v_count3 number;
v_rn number;
begin
for c_row in c_job loop
v_count3:=2;
select t.grant_code into v_grant_code from project t where t.prj_code in(select a.prj_code from acceptance a where a.act_code=c_row.act_code);
if instr(',429,198,199,200,201,202,203,204,',','||v_grant_code||',')>0 then
v_wf_id:=120000103;
else
v_wf_id:=100000401;
end if;
select count(0) into v_count1 from audit_comment t where t.key_code=c_row.act_code and t.comment_type='acceptance_final';
select count(0) into v_count2 from wf_his_task t where t.op_code=c_row.act_code and t.wf_id=v_wf_id and t.status!='00';
if v_count1>0 and v_count1=v_count2 then
for i in 1..v_count1 loop
select rn,status into v_rn,v_status from (select rownum rn,status from wf_his_task w where w.wf_id=v_wf_id and w.status!='00' and w.op_code=c_row.act_code and rownum<v_count3 order by w.id ) where rn>=i;
update audit_comment t set t.status=v_status
where t.seq_no in(select seq_no from (select seq_no,rownum rn from audit_comment t where t.key_code=c_row.act_code and t.comment_type='acceptance_final' and rownum<v_count3 order by t.seq_no) where rn>=i);
v_count3:=v_count3+1;
end loop;
end if;
end loop;
end;
end repair_accept_final_x_20160520;
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- ORACLE LATERAL-SQL-INJECTION 个人见解