Oracle 11G 重复 output_put.put_line 两次。如何解决这个问题?

Oracle 11G repeats output_put.put_line twice. How to solve this?

我的循环给了我两倍的结果。因为我只想要一次。我该怎么办?

 for i in 1..length(newStudentNumber) loop
    character := SUBSTR(newStudentNumber, i, 1);
    newStudentNumber := newStudentNumber || case character
     when 'A' then '16'
     when 'B' then '17'
     when 'C' then '18'
     when 'D' then '19'
     when 'E' then '20'
     when 'F' then '21'
     when 'G' then '22'
     when 'H' then '23'
     when 'I' then '24'
     when 'J' then '25'
     when 'K' then '26'
     when 'L' then '27'
     when 'M' then '28'
     when 'N' then '29'
     when 'O' then '30'
     when 'P' then '31'
     when 'Q' then '32'
     when 'R' then '33'
     when 'S' then '34'
     when 'T' then '35'
     when 'U' then '36'
     when 'V' then '37'
     when 'W' then '38'
     when 'X' then '39'
     when 'Y' then '40'
     when 'Z' then '41'
     else character
    end;
  end loop;
  dbms_output.put_line(newStudentNumber);

我希望我对这个问题不是太含糊

提前致谢

在你的循环中,你将可能转换的字符附加到你正在循环的同一个字符串变量,newStudentNumber。如果您不想要旧值和新值,那么您需要在循环中填充的第二个变量。

  -- new variable, which has to be declared
  convertedStudentNumber := null;
  for i in 1..length(newStudentNumber) loop
    character := SUBSTR(newStudentNumber, i, 1);
    convertedStudentNumber := convertedStudentNumber || case character
    ...
    else character
    end;
  end loop;
  dbms_output.put_line(convertedStudentNumber);

现在两个变量有不同的值,一个开始于TUE...,另一个开始于353620...