当我将多个选择查询输出假脱机到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;
答案 0 :(得分:1)
尝试TRIMSPOOL
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
我将您的脚本更改为
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;
输出
$ 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;