【问题标题】:when i am trying to sort the array its giving an error当我试图对数组进行排序时,它给出了一个错误
【发布时间】:2015-02-02 18:55:20
【问题描述】:
DECLARE
TYPE myarray is varray(10) of pls_integer;
unsorted myarray := myarray();
min pls_integer;
begin
  unsorted := myarray(2,5,8,6,4,9,1,3,7,10);
  FOR i in 1 .. unsorted.count-1 loop
  begin 
   for j in i+1 .. unsorted.count loop
   begin
    if(unsorted(j)<unsorted(i))
    then 
      begin
        min := unsorted(i); 
        unsorted(i) := unsorted(j);
        unsorted(j) := min; 
      end;
     end if;
 end;
 end loop;
 dbms_output.put_line(unsorted(i));
 end;
 end loop;
 end;

我的代码给出错误我无法理解为什么? ORA-06550:第 16 行,第 31 列: PLS-00103:遇到符号“;”预期以下情况之一时:

【问题讨论】:

  • 冒泡排序?使您的集合成为 SQL 类型,然后使用 select 对其进行排序。

标签: oracle plsql


【解决方案1】:

您使用min 作为变量,但min 是保留关键字。改用另一个变量名,它应该可以工作。

【讨论】:

    猜你喜欢
    • 2020-10-02
    • 2023-01-30
    • 1970-01-01
    • 2023-02-17
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多