Oracle trimspool only trailing blanks (not leading blanks)

为君一笑 提交于 2019-12-10 13:34:04

问题


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)

回答1:


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.



来源:https://stackoverflow.com/questions/4760926/oracle-trimspool-only-trailing-blanks-not-leading-blanks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!