plsql 写冒泡排序

    技术2022-05-20  29

    create or replace procedure pr_bubble_Sort(in_arry in varchar2)istype one_arr is table of number index by binary_integer;my_one_arr one_arr;n_cur_index number(6):=0;

    n_inner_index number(6):=0;n_temp number(6);begin   for i in (select regexp_substr(in_arry,'[^,]+',1,rownum) my_date from dual                    connect by rownum<= length(in_arry) - length(replace(in_arry,',',''))+1)   loop         n_cur_index := n_cur_index +1;         my_one_arr(n_cur_index) := i.my_date;   end loop;      if in_arry  is not null then         n_inner_index := n_cur_index;                  for j in 1..n_cur_index         loop             n_inner_index := n_inner_index -1;             for k in 1..n_inner_index             loop                if my_one_arr(k) > my_one_arr(k+1) then                   n_temp := my_one_arr(k);                   my_one_arr(k) := my_one_arr(k+1);                   my_one_arr(k+1) := n_temp;                end if;             end loop;         end loop;                  for l in 1..n_cur_index          loop             dbms_output.put_line(my_one_arr(l));         end loop;         end if ;

    end;


    最新回复(0)