Oracle 假脱机设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5228952/
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 22:57:16  来源:igfitidea点击:

Oracle Spool setting

sqloracleplsql

提问by Arav

When i spool the multiple select query output to a txt file. I see empty new lines after each select query how can i get rid of it.

当我将多选查询输出假脱机到 txt 文件时。我在每个选择查询后看到空的新行,我该如何摆脱它。

define spool_file = 'D:\test1'

--set serveroutput on;

SET ECHO OFF

SET NEWPAGE 0

SET SPACE 0

SET PAGESIZE 0

SET FEEDBACK OFF

SET HEADING OFF


-- set echo on  ;

spool D:\test1;

select 'H,correction.csv,'  ||  to_char(sysdate,'DD/MM/YYYY')  from dual;

select 'D,' ||record_id      from cl_record where status=15;

select 'T,correction.csv,' from cl_record where status=15;

spool off;

回答by Alain Pannetier

Try TRIMSPOOL

试试 TRIMSPOOL

SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON

I changed your script to

我把你的脚本改成了

define spool_file = '/home/alain/test.log'
--set serveroutput on;
SET ECHO OFF
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET trimspool on
--set echo on ;
spool /home/alain/test.log;
select sysdate from dual;
select 'hello ' || 'world' from dual;
spool off;

The output was

输出是

$ cat test.log
SQL> select sysdate from dual;
03-08-2011 07:48:26
SQL> select 'hello ' || 'world' from dual;
hello world
SQL> spool off;