Home » SQL & PL/SQL » SQL & PL/SQL » Outputting leading spaces with serverouput within SQL*PLUS
Outputting leading spaces with serverouput within SQL*PLUS [message #36922] Fri, 04 January 2002 02:51 Go to next message
Fan Timmermans
Messages: 1
Registered: January 2002
Junior Member
Hello,
i created a procedure which produces output using DBMS_OUTPUT.PUT_LINE. The output is formatted and sometimes there are leading (left-trailing) spaces.
I'm very surprised to find out that within SQL*Plus these trailing spaces are not present into the spool file. While using TOAD (Quest Software) the DBMS_OUTPUT shows exactly what I created using PUT_LINE.
Has anyone a suggestion?
kind regards
Fan Timmermans
Mediaan/abs bv
the Netherlands.

----------------------------------------------------------------------
Re: Outputting leading spaces with serverouput within SQL*PLUS [message #36924 is a reply to message #36922] Fri, 04 January 2002 04:09 Go to previous messageGo to next message
RYAN
Messages: 22
Registered: December 2000
Junior Member
never used toad in "command line" mode like you describe, but sqlplus drops leading spaces on dbms_output.

i've always prefaced every line with a ., and then spaced out from there.

r.

----------------------------------------------------------------------
Re: Outputting leading spaces with serverouput within SQL*PLUS [message #36930 is a reply to message #36922] Fri, 04 January 2002 04:49 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
use rpad.

look at this example:

declare
cursor c1 is select * from emp;
begin
for i in c1 loop
dbms_output.put_line(rpad(i.empno,10,' ')||rpad(i.ename,30,' ')||rpad(i.sal,10,' '));
end loop;
end;

above example prints with spaces.

Note: remember, parameter to dbms_output.put_line procedure must be less than or equal to 255.

Suresh Vemulapalli

----------------------------------------------------------------------
Re: Outputting leading spaces with serverouput within SQL*PLUS [message #36974 is a reply to message #36930] Tue, 08 January 2002 09:38 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
it's a sqlplus "feature"

You need to specify "format wrapped" as shown below:
set serveroutput on size 1000000 format wrapped
begin
dbms_output.put_line('        hello world');
dbms_output.put_line('........hello world');
end;
/
Previous Topic: single quote problem
Next Topic: Using a text file in PlSql
Goto Forum:
  


Current Time: Tue Aug 11 17:46:06 CDT 2020