SQL——存储过程实例 循环

--循环
create or replace procedure p_xunhuan(input in number,output out number) is

       temp number(10);

begin

       temp := 0;
       
       for temp in 0..input loop
           begin
                output := input+temp;
                dbms_output.put_line('----'||output);
           end;
       end loop;
       
end p_xunhuan;

运行存储过程:

declare 
     sr number;--输入参数
     sc number;--输出参数
begin
     sr := 7;
     p_xunhuan(sr,sc);
end;

结果:

----7
----8
----9
----10
----11
----12
----13
----14
逃避不一定躲得过,面对不一定最难过
原文地址:https://www.cnblogs.com/yangzhenlong/p/3542974.html