DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: dbms_output.put_line -- how to put an empty line?

  1. #1
    Join Date
    May 2001
    Posts
    285
    Hi,

    How can I put an empty line in the pl/sql output to make reading easier? i.e. I'd like to separate the output so they won't all grouped together which is hard to read.

    I tried to put

    dbms_output.put_line(' ');

    into my pl/sql code, but it is just get skipped.

    Any idea? Thanks!

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Use ASCII sequence for LF or CR+LF (ascii 10 and 13):

    SQL> begin
    2 dbms_output.put_line(sysdate);
    3 dbms_output.put(CHR(10));
    4 dbms_output.put_line(sysdate);
    5 end;
    6 /
    28.09.01

    28.09.01
    PL/SQL procedure successfully completed.

    If you are doing this in SQL*Plus then you can use the following setting:
    SET SERVEROUTPUT ON FORMAT WRAPPED

    SQL> set serveroutput on format wrapped
    SQL> begin
    2 dbms_output.put_line(sysdate);
    3 dbms_output.put_line('');
    4 dbms_output.put_line(sysdate);
    5 end;
    6 /
    28.09.01

    28.09.01
    PL/SQL procedure successfully completed.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Originally posted by jmodic
    dbms_output.put(CHR(10));
    CHR(10) does the same as dbms_output.new_line;

  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    No, it does not. At least not in SQL*Plus with the default setting of SERVEROUTPUT FORMAT WORD_WRAPPED.

    SQL> set serveroutput on
    SQL> begin
    2 dbms_output.put_line(sysdate);
    3 dbms_output.new_line;
    4 dbms_output.put_line(sysdate);
    5 end;
    6 /
    29.09.01
    29.09.01

    PL/SQL procedure successfully completed.

    SQL>
    SQL> begin
    2 dbms_output.put_line(sysdate);
    3 dbms_output.put(CHR(10));
    4 dbms_output.put_line(sysdate);
    5 end;
    6 /
    29.09.01

    29.09.01

    PL/SQL procedure successfully completed.

    See, in the first case there is no separate line between the two lines with the date. That is because with the sefault setting Oracle trims all leading spaces and also skips all "empty" lines. If you wan't to prevent this you must set SERVEROUTPUT FORMAT WRAPPED as I have indicated in my first reply.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  5. #5
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    :-) Well, set then SERVEROUTPUT FORMAT WRAPPED

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width