oracle按rownum更新数据

本文介绍了一段 Oracle PL/SQL 存储过程代码,该过程用于从验收表中选择符合条件的记录,并根据审计评论表和工作流历史任务表中的数据更新审计评论表的状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;

--详细按rownum更新注意查看此处就行了
           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;

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值