10的阶乘
简单(loop)循环
1 declare
2 i number(2) :=1;
3 s number(10):=1;
4 name varchar(8):=' simple';
5 begin
6 loop
7 s:=s*i;
8 i:=i+1;
9 dbms_output.put_line(s||''||name);
10 exit when i>10;
11 end loop;
12* end;
---------------------------------------------------可爱的分割线(脸红)--------------------------------------------------------
for循环
1 declare
2 i number(2) :=1;
3 s number(10):=1;
4 name varchar(8):=' for';
5 begin
6 loop
7 s:=s*i;
8 i:=i+1;
9 dbms_output.put_line(s||''||name);
10 end loop;
11* end;
SQL> /
1 for
2 for
6 for
24 for
120 for
720 for
5040 for
40320 for
362880 for
3628800 for
---------------------------------------------------可爱的分割线(脸红)--------------------------------------------------------
while循环
1 declare
2 i number(2) :=1;
3 s number(10):=1;
4 name varchar(8):=' while';
5 begin
6 while i /
1 while
2 while
6 while
24 while
120 while
720 while
5040 while
40320 while
362880 while
3628800 while
作业帮用户
2017-10-24
举报