摘錄你的第二個存儲過程的代碼:
FOR player IN rows LOOP
currentCount := maxCount;
DBMS_OUTPUT.PUT(player.FIRSTNAME || ' ' || player.LASTNAME || ':' || player.points || ' ');
--DBMS_OUTPUT.NEW_LINE();
END LOOP;
如果你想所產生的輸出呈現在您應循環(循環後)以外的移動DBMS_OUTPUT.NEW_LINE()
一個行。所以,你的代碼看起來像:
FOR player IN rows LOOP
currentCount := maxCount;
DBMS_OUTPUT.PUT(player.FIRSTNAME || ' ' || player.LASTNAME || ':' || player.points || ' ');
END LOOP;
DBMS_OUTPUT.NEW_LINE();
保持DBMS_OUTPUT.NEW_LINE();
內環路DBMS_OUTPUT.PUT
後,你只是模仿DBMS_OUTPUT.PUT_LINE
程序。
SQL> create or replace procedure output1
2 is
3 l_str varchar2(100);
4 l_status number;
5 begin
6 for i in 1..7
7 loop
8 dbms_output.put('Text_' || To_char(i));
9 dbms_output.new_line;
10 end loop;
11 end;
12/
Procedure created
SQL>
SQL> create or replace procedure output2
2 is
3 l_str varchar2(100);
4 l_status number;
5 begin
6 for i in 1..7
7 loop
8 dbms_output.put('Text_' || To_char(i));
9 end loop;
10 dbms_output.new_line;
11 end;
12/
Procedure created
SQL> exec output1;
Text_1
Text_2
Text_3
Text_4
Text_5
Text_6
Text_7
PL/SQL procedure successfully completed
SQL> exec output2;
Text_1Text_2Text_3Text_4Text_5Text_6Text_7
PL/SQL procedure successfully completed
在您的代碼:
SET serveroutput ON size 32000;
REM Change output file name TO proj3-NetID.OUT!
SPOOL proj3-hgeorge3.OUT;
exec DBMS_OUTPUT.enable('100000000');
如果使用serveroutput
選項(設置爲ON),那麼就沒有必要調用DBMS_OUTPUT.enable
程序。如果碰巧叫DBMS_OUTPUT.enable
,那麼數字數據類型的值應該作爲參數傳入而不是字符串。是的,會有數據類型的隱式轉換,但最好避免它。緩衝區的最大大小是100萬。
您是否嘗試在循環後添加'DBMS_OUTPUT.NEW_LINE();'?我的意思是畢竟'DBMS_OUTPUT.PUT()'命令? –