1000行?很简单啊,给你写个例子吧
16:26:12 SQL> create or replace procedure tes as
16:26:13 2 i integer;
16:26:13 3 j integer;
16:26:13 4 tp_num integer;
16:26:13 5 result varchar(10);
16:26:13 6 type arr is array(5) of integer;
16:26:13 7 arr1 arr:=arr(abs(mod(dbms_random.random,10)),abs(mod(dbms_random.
random,10)),abs(mod(dbms_random.random,10)),abs(mod(dbms_random.random,10)),abs(
mod(dbms_random.random,10)));
16:26:13 8 begin
16:26:13 9 for i in 1..5 loop
16:26:13 10 dbms_output.put_line(arr1(i));
16:26:13 11 end loop;
16:26:13 12
16:26:13 13 for i in 1..5 loop
16:26:13 14 for j in i+1..5 loop
16:26:13 15 if arr1(i)<arr1(j) then
16:26:13 16 tp_num:=arr1(i);
16:26:13 17 arr1(i):=arr1(j);
16:26:13 18 arr1(j):=tp_num;
16:26:13 19 end if;
16:26:13 20 end loop;
16:26:13 21 end loop;
16:26:13 22
16:26:13 23 for i in 1..5 loop
16:26:13 24 result:=result||arr1(i);
16:26:13 25 end loop;
16:26:13 26
16:26:13 27 dbms_output.put_line(result);
16:26:13 28 end;
16:26:13 29 /过程已创建。已用时间: 00: 00: 00.32
16:26:14 SQL> exec tes
1
2
7
4
0
74210PL/SQL 过程已成功完成。已用时间: 00: 00: 00.16
16:26:12 SQL> create or replace procedure tes as
16:26:13 2 i integer;
16:26:13 3 j integer;
16:26:13 4 tp_num integer;
16:26:13 5 result varchar(10);
16:26:13 6 type arr is array(5) of integer;
16:26:13 7 arr1 arr:=arr(abs(mod(dbms_random.random,10)),abs(mod(dbms_random.
random,10)),abs(mod(dbms_random.random,10)),abs(mod(dbms_random.random,10)),abs(
mod(dbms_random.random,10)));
16:26:13 8 begin
16:26:13 9 for i in 1..5 loop
16:26:13 10 dbms_output.put_line(arr1(i));
16:26:13 11 end loop;
16:26:13 12
16:26:13 13 for i in 1..5 loop
16:26:13 14 for j in i+1..5 loop
16:26:13 15 if arr1(i)<arr1(j) then
16:26:13 16 tp_num:=arr1(i);
16:26:13 17 arr1(i):=arr1(j);
16:26:13 18 arr1(j):=tp_num;
16:26:13 19 end if;
16:26:13 20 end loop;
16:26:13 21 end loop;
16:26:13 22
16:26:13 23 for i in 1..5 loop
16:26:13 24 result:=result||arr1(i);
16:26:13 25 end loop;
16:26:13 26
16:26:13 27 dbms_output.put_line(result);
16:26:13 28 end;
16:26:13 29 /过程已创建。已用时间: 00: 00: 00.32
16:26:14 SQL> exec tes
1
2
7
4
0
74210PL/SQL 过程已成功完成。已用时间: 00: 00: 00.16
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货