oracle存储过程

create or replace procedure inserttestdata
(
   v_count        in   number,
   v_startuserid  in   varchar2,
   v_returnval    out  number )
as
   v_opertime           varchar2(20);
   v_current_count      number(10);
   v_temp_userid        varchar2(20);
begin
   v_opertime   := to_char(sysdate,'yyyy.mm.dd');
   v_current_count      := 0;
   v_temp_userid        := v_startuserid;
  
   while 1=1 loop
   savepoint begin_tran;
   begin
      insert into ardinf(userid ,opertime)
       values(v_temp_userid ,v_opertime);
        exception
      when others then
      begin
         rollback to savepoint begin_tran;
         DBMS_OUTPUT.PUT_LINE('exception!');
         DBMS_OUTPUT.PUT_LINE(v_temp_userid);
         v_returnval := 1008;
         exit;
         --exit
之后的代码无法执行
         DBMS_OUTPUT.PUT_LINE('After exit!Before return');
         DBMS_OUTPUT.PUT_LINE(v_returnval);
         return;
         DBMS_OUTPUT.PUT_LINE(v_returnval);
      end;
   end;
   if v_current_count >= v_count-1 then
      begin
          DBMS_OUTPUT.PUT_LINE('over and exit!');
          exit;
      end;
   end if;    
   commit;
   v_current_count:=v_current_count+1;
   v_temp_userid:=to_char(to_number(v_temp_userid)+1);
   if mod(v_current_count,10000)=0 then
      DBMS_OUTPUT.PUT_LINE(v_current_count);
   end if;   
   end loop;
   commit;
   DBMS_OUTPUT.PUT_LINE(v_returnval);
   return;
end inserttestdata;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值