oracle 如何在假脱机输出时删除尾随空格和额外的新行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6339358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:57:31  来源:igfitidea点击:

How can I remove trailing spaces & extra new line while spooling output?

sqloracleoracle10gsqlplus

提问by Arav

Trailing spaces in the spooled output rpad(' ',40) are getting truncated. If i remove the SET TRIMSPOOL on option the line size becomes 400 and there is a extra new line after each select query. What options i need to have the trailing spaces at the end and remove the extra new line.

假脱机输出 rpad(' ',40) 中的尾随空格被截断。如果我删除 SET TRIMSPOOL on 选项,则行大小变为 400,并且每次选择查询后都会有一个额外的新行。我需要哪些选项在末尾添加尾随空格并删除额外的新行。

SET SERVEROUTPUT ON
SET VERIFY OFF
SET FEEDBACK OFF
SET HEADING OFF
SET LINESIZE 400
SET TRIMSPOOL ON
SET PAGESIZE 0
SPOOL ${T_SPOOL}    

SELECT '0' || rpad(' ',17) || '01' || 'WBC' || rpad(' ',7) || rpad('Accounts ',26) ||     '407081' || rpad('REF',12)  || to_char(sysdate, 'DDMMYY') || rpad(' ',40)
from dual;

回答by Tony Andrews

Since your lines all have the same fixed length, you can remove the TRIMSPOOL setting and change the LINESIZE setting to match the length required e.g.

由于您的线条都具有相同的固定长度,您可以删除 TRIMSPOOL 设置并更改 LINESIZE 设置以匹配所需的长度,例如

SET LINESIZE 120

(120 was the figure I came up with via a quick mental tot-up, it may be incorrect).

(120 是我通过快速的心理总结得出的数字,可能不正确)。