I am wondering if there's any tricks to get trimspool
to only trim trailing whitespace on the right.
I have code that uses dbms_output.put_line to print to the console, and the output often has indentation to make it easier to scan with the eyes. I set the line width rather large to make some of the output easier to read, so I also set trimspool to get rid of extra white space. The only problem is that now the leading which space is removed as well as the trailing whitespace. Is there a way to fix this? I could add a leading (before the leading whitespace) ".
" character to some of the output statements, but I'm not allowed to modify the code in most of the packages.
Here's what it outputs with no trimmimg:
level 1 (EOL) level 2 (EOL) Some data (EOL)
Here's what it currently outputs with trimspool
on:
level 1(EOL) level 2(EOL) Some data(EOL)
HEre's what I want:
level 1(EOL) level 2(EOL) Some data(EOL)
The Oracle documentation says this about removing trailing spaces with "set trimspool" or "set trimout" commands: SET TRIMOUT ON or SET TRIMSPOOL ON removes trailing blanks at the end of each displayed or spooled line. Setting these variables ON can reduce the amount of data written.
The Oracle TRIM function is used to remove all leading or trailing characters (or both) from a character string. If trim_character or trim_source is a character literal, then it is necessary to enclose it in single quotation marks. When no trim_character is specified, then the default value is a blank space.
The TRIMSPOOL setting controls whether SQL*Plus writes trailing spaces when spooling data to a file. The default setting is OFF, which causes SQL*Plus to write each line to the spool file in its entirety, trailing spaces and all.
SET HEADS[EP] Is the command, which may be abbreviated SET HEADS. heading_separator. Is the new heading separator character, which may be used in subsequent COLUMN commands to mark line breaks in multiline column headings.
I guess you're after
set serveroutput on size 100000 format wrapped
if I do understand your question.
If I do this:
set serveroutput on size 1000000
begin
dbms_output.put_line('no indent');
dbms_output.put_line(' indent');
end;
/
SQL*Plus outputs:
no indent
indent
If, however, I do
set serveroutput on size 1000000 format truncated
begin
dbms_output.put_line('no indent');
dbms_output.put_line(' indent');
end;
/
SQL*Plus outputs:
no indent
indent
You have to set trimspool on
in order to eliminate the spaces up to eol
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With