Bufferten innehåller tecken, men den överlämnar dem rad för rad. PUT slutför aldrig raden, så det finns inget att överlämna ännu.
Se det själv
SQL> exec dbms_output.put_line('hello') hello PL/SQL procedure successfully completed. SQL> exec dbms_output.put('hello again') PL/SQL procedure successfully completed. SQL> exec dbms_output.put(' and again') PL/SQL procedure successfully completed. SQL> exec dbms_output.new_line hello again and again PL/SQL procedure successfully completed. Vad dokumentationen säger
DBMS_OUTPUT-referensen noterar att "SQL*Plus calls GET_LINES after issuing a SQL statement or anonymous PL/SQL calls", och GET_LINES "retrieves an array of lines from the buffer".
NEW_LINE säger det rakt: "This procedure puts an end-of-line marker. The GET_LINE Procedure and the GET_LINES Procedure return 'lines' as delimited by 'newlines'. Every call to the PUT_LINE Procedure or NEW_LINE Procedure generates a line that is returned by GET_LINE(S)."
Praktisk implikation
Om du bygger utdata i bitar med PUT, avsluta alltid med NEW_LINE eller PUT_LINE. Annars stannar den avslutande fragmentet kvar i bufferten och, om din session avslutas utan att spola, går förlorat helt. Hälsningar, Rob.